Skip to content

Commit

Permalink
#213 Add check for keys permissions in the test in governance drep ke…
Browse files Browse the repository at this point in the history
…y-gen
  • Loading branch information
carbolymer committed Oct 24, 2023
1 parent 8465389 commit 8f3e163
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ test-suite cardano-cli-golden
, time
, transformers
, unordered-containers
, unix
build-tool-depends: cardano-cli:cardano-cli
, tasty-discover:tasty-discover

Expand Down
14 changes: 14 additions & 0 deletions cardano-cli/test/cardano-cli-golden/Test/Golden/Governance/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
module Test.Golden.Governance.DRep where

import Control.Monad (void)
import Data.Bits ((.&.))
import GHC.Stack (withFrozenCallStack)
import Numeric (showOct)
import System.Posix.Files (fileMode, getFileStatus)

import Test.Cardano.CLI.Util (execCardanoCLI, noteInputFile, noteTempFile, propertyOnce)

Expand Down Expand Up @@ -30,6 +34,16 @@ hprop_golden_governanceDRepKeyGen =
H.assertFileOccurences 1 "Delegate Representative Verification Key" verificationKeyFile
H.assertFileOccurences 1 "Delegate Representative Signing Key" signingKeyFile

vrfMode <- retrievePermissions verificationKeyFile
sgnMode <- retrievePermissions verificationKeyFile

vrfMode === "600"
sgnMode === "600"
where
retrievePermissions path = withFrozenCallStack $ do
mode <- H.evalIO $ fileMode <$> getFileStatus path
pure $ showOct (mode .&. 0o777) "" -- we only need the 3 lowest octets here

hprop_golden_governance_drep_id_bech32 :: Property
hprop_golden_governance_drep_id_bech32 =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
Expand Down

0 comments on commit 8f3e163

Please sign in to comment.