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 2db6b16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

module Test.Golden.Governance.DRep where

import Control.Monad (void)
import Control.Monad (unless, 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)

import Hedgehog
import qualified Hedgehog as H
import Hedgehog.Extras.Stock (isWin32)
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.File as H
import qualified Hedgehog.Extras.Test.Golden as H
Expand All @@ -30,6 +35,17 @@ hprop_golden_governanceDRepKeyGen =
H.assertFileOccurences 1 "Delegate Representative Verification Key" verificationKeyFile
H.assertFileOccurences 1 "Delegate Representative Signing Key" signingKeyFile

unless isWin32 $ do
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 2db6b16

Please sign in to comment.