Skip to content

Commit

Permalink
Merge pull request #401 from input-output-hk/mgalazyn/fix/add-check-f…
Browse files Browse the repository at this point in the history
…or-permissions-in-key-gen

#213 Add check for keys permissions in the test in governance drep key-gen
  • Loading branch information
carbolymer authored Oct 26, 2023
2 parents adefcce + fd6ebe2 commit fced0aa
Show file tree
Hide file tree
Showing 2 changed files with 26 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 @@ -330,6 +330,7 @@ test-suite cardano-cli-test

test-suite cardano-cli-golden
import: project-config
, maybe-unix

hs-source-dirs: test/cardano-cli-golden
main-is: cardano-cli-golden.hs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{-# LANGUAGE CPP #-}
{- HLINT ignore "Use camelCase" -}

module Test.Golden.Governance.DRep where

import Control.Monad (void)
#if !defined(mingw32_HOST_OS)
#define UNIX
#endif

import Control.Monad

#ifdef UNIX
import Data.Bits ((.&.))
import GHC.Stack (withFrozenCallStack)
import Numeric (showOct)
import System.Posix.Files (fileMode, getFileStatus)
#endif

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

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

#ifdef UNIX
vrfMode <- retrievePermissions verificationKeyFile
sgnMode <- retrievePermissions signingKeyFile

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
#endif

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 fced0aa

Please sign in to comment.