diff options
-rw-r--r-- | kiki.cabal | 1 | ||||
-rw-r--r-- | testkiki/testkiki.hs | 27 |
2 files changed, 22 insertions, 6 deletions
@@ -60,7 +60,6 @@ Executable hosts | |||
60 | 60 | ||
61 | Executable cokiki | 61 | Executable cokiki |
62 | Main-is: cokiki.hs | 62 | Main-is: cokiki.hs |
63 | Buildable: False | ||
64 | Build-Depends: base >=4.6.0.0, | 63 | Build-Depends: base >=4.6.0.0, |
65 | bytestring, | 64 | bytestring, |
66 | unix, | 65 | unix, |
diff --git a/testkiki/testkiki.hs b/testkiki/testkiki.hs index aa93e2c..0e4c70a 100644 --- a/testkiki/testkiki.hs +++ b/testkiki/testkiki.hs | |||
@@ -56,11 +56,14 @@ main = do | |||
56 | 56 | ||
57 | doTests :: TestKikiSettings -> IO () | 57 | doTests :: TestKikiSettings -> IO () |
58 | doTests tkConfig = hspec $ do | 58 | doTests tkConfig = hspec $ do |
59 | {- | ||
60 | -- Example of shouldThrow | ||
59 | describe "TODO: error" $ | 61 | describe "TODO: error" $ |
60 | it "throws an exception" $ | 62 | it "throws an exception" $ |
61 | evaluate (error "TODO:testsuite") `shouldThrow` anyException | 63 | evaluate (error "TODO:testsuite") `shouldThrow` anyException |
64 | -} | ||
62 | 65 | ||
63 | describe "export-public" $ do | 66 | describe "kiki export-public" $ do |
64 | it "does not modify mtime of GNUPGHOME keyrings" $ do | 67 | it "does not modify mtime of GNUPGHOME keyrings" $ do |
65 | pending | 68 | pending |
66 | it "creates external pem files which do not exist" $ do | 69 | it "creates external pem files which do not exist" $ do |
@@ -68,7 +71,7 @@ doTests tkConfig = hspec $ do | |||
68 | it "does not leak secret data from GNUPGHOME keyrings" $ do | 71 | it "does not leak secret data from GNUPGHOME keyrings" $ do |
69 | pending | 72 | pending |
70 | 73 | ||
71 | describe "export-secret" $ do | 74 | describe "kiki export-secret" $ do |
72 | it "fails when public keys in existing PEM files do not match" $ do | 75 | it "fails when public keys in existing PEM files do not match" $ do |
73 | pending | 76 | pending |
74 | it "updates public pem files to private ones when told to" $ do | 77 | it "updates public pem files to private ones when told to" $ do |
@@ -76,7 +79,7 @@ doTests tkConfig = hspec $ do | |||
76 | it "creates external pem files which do not exist" $ do | 79 | it "creates external pem files which do not exist" $ do |
77 | pending | 80 | pending |
78 | 81 | ||
79 | describe "init" $ do | 82 | describe "kiki init" $ do |
80 | it "honors GNUPGHOME environment variable" $ do | 83 | it "honors GNUPGHOME environment variable" $ do |
81 | let kiki = kiki'Env tkConfig | 84 | let kiki = kiki'Env tkConfig |
82 | (isInfixOf "New packet" <$> kiki ["init"]) `shouldReturn` True | 85 | (isInfixOf "New packet" <$> kiki ["init"]) `shouldReturn` True |
@@ -101,12 +104,25 @@ doTests tkConfig = hspec $ do | |||
101 | output <- kiki ["init"] | 104 | output <- kiki ["init"] |
102 | b <- doesFileExist (chroot tkConfig </> "root" </> ".gnupg" </> "secring.gpg") | 105 | b <- doesFileExist (chroot tkConfig </> "root" </> ".gnupg" </> "secring.gpg") |
103 | (isInfixOf "New packet" output && b ) `shouldBe` True | 106 | (isInfixOf "New packet" output && b ) `shouldBe` True |
107 | |||
108 | describe "cokiki ssh-client" $ do | ||
109 | it "does something" $ | ||
110 | pending | ||
111 | |||
112 | describe "cokiki ssh-server" $ do | ||
113 | it "does something" $ | ||
114 | pending | ||
115 | |||
116 | describe "cokiki strongswan" $ do | ||
117 | it "does something" $ | ||
118 | pending | ||
104 | where | 119 | where |
105 | kiki'Env config args = do | 120 | kiki'Env config args = do |
106 | setEnv "GNUPGHOME" (gnupghome config) | 121 | setEnv "GNUPGHOME" (gnupghome config) |
107 | let args' = args ++ ["--chroot=" ++ chroot config] | 122 | let args' = args ++ ["--chroot=" ++ chroot config] |
108 | readProcess "./dist/build/kiki/kiki" args' "" | 123 | r <- readProcess "./dist/build/kiki/kiki" args' "" |
109 | unsetEnv "GNUPGHOME" | 124 | unsetEnv "GNUPGHOME" |
125 | return r | ||
110 | 126 | ||
111 | kiki'No'Env'No'Home config args = do | 127 | kiki'No'Env'No'Home config args = do |
112 | let args' = args ++ ["--chroot=" ++ chroot config] | 128 | let args' = args ++ ["--chroot=" ++ chroot config] |
@@ -119,8 +135,9 @@ doTests tkConfig = hspec $ do | |||
119 | kiki'Env'And'HomeArg config args = do | 135 | kiki'Env'And'HomeArg config args = do |
120 | setEnv "GNUPGHOME" (gnupghome config) | 136 | setEnv "GNUPGHOME" (gnupghome config) |
121 | let args' = args ++ ["--chroot=" ++ chroot config,"--home=" ++ gnupghome config] | 137 | let args' = args ++ ["--chroot=" ++ chroot config,"--home=" ++ gnupghome config] |
122 | readProcess "./dist/build/kiki/kiki" args' "" | 138 | r <- readProcess "./dist/build/kiki/kiki" args' "" |
123 | unsetEnv "GNUPGHOME" | 139 | unsetEnv "GNUPGHOME" |
140 | return r | ||
124 | 141 | ||
125 | -- UTILS | 142 | -- UTILS |
126 | isInfixOf sub str = let (_,match) = B.breakSubstring (B.pack sub) (B.pack str) | 143 | isInfixOf sub str = let (_,match) = B.breakSubstring (B.pack sub) (B.pack str) |