Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#213 Add check for keys permissions in the test in governance drep key-gen #401

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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