packages feed

HsOpenSSL 0.11.3.1 → 0.11.3.2

raw patch · 7 files changed

+75/−72 lines, 7 filesdep −HUnitdep −test-frameworkdep −test-framework-hunitPVP ok

version bump matches the API change (PVP)

Dependencies removed: HUnit, test-framework, test-framework-hunit

API changes (from Hackage documentation)

Files

ChangeLog view
@@ -1,3 +1,10 @@+2016-10-17  Vladimir Shabanov  <vshabanoff@gmail.com>++	* HsOpenSSL.cabal (Version): Bump version to 0.11.3.2++	* Test/*, HsOpenSSL.cabal (Build-Depends):+	Removed HUnit, test-framework and test-framework-hunit dependencies.+ 2016-10-15  Vladimir Shabanov  <vshabanoff@gmail.com>  	* HsOpenSSL.cabal (Version): Bump version to 0.11.3.1
HsOpenSSL.cabal view
@@ -12,7 +12,7 @@     <http://hackage.haskell.org/package/tls>, which is a pure Haskell     implementation of SSL.     .-Version:       0.11.3.1+Version:       0.11.3.2 License:       PublicDomain License-File:  COPYING Author:        Adam Langley, Mikhail Vorozhtsov, PHO, Taru Karttunen@@ -147,13 +147,11 @@ Test-Suite test-cipher     Type:    exitcode-stdio-1.0     Main-Is: Test/OpenSSL/Cipher.hs+    Other-Modules: Test.OpenSSL.TestUtils     Build-Depends:         HsOpenSSL,-        HUnit                >= 1.0 && < 1.5,         base                 >= 4.4 && < 5,-        bytestring           >= 0.9 && < 0.11,-        test-framework       >= 0.8 && < 0.9,-        test-framework-hunit >= 0.3 && < 0.4+        bytestring           >= 0.9 && < 0.11     Default-Language:         Haskell2010     GHC-Options:@@ -162,13 +160,11 @@ Test-Suite test-dsa     Type:    exitcode-stdio-1.0     Main-Is: Test/OpenSSL/DSA.hs+    Other-Modules: Test.OpenSSL.TestUtils     Build-Depends:         HsOpenSSL,-        HUnit                >= 1.0 && < 1.5,         base                 >= 4.4 && < 5,-        bytestring           >= 0.9 && < 0.11,-        test-framework       >= 0.8 && < 0.9,-        test-framework-hunit >= 0.3 && < 0.4+        bytestring           >= 0.9 && < 0.11     Default-Language:         Haskell2010     GHC-Options:@@ -177,13 +173,10 @@ Test-Suite test-der     Type:    exitcode-stdio-1.0     Main-Is: Test/OpenSSL/DER.hs+    Other-Modules: Test.OpenSSL.TestUtils     Build-Depends:         HsOpenSSL,-        HUnit                >= 1.0 && < 1.5,-        base                 >= 4.4 && < 5,-        bytestring           >= 0.9 && < 0.11,-        test-framework       >= 0.8 && < 0.9,-        test-framework-hunit >= 0.3 && < 0.4+        base                 >= 4.4 && < 5     Default-Language:         Haskell2010     GHC-Options:@@ -192,13 +185,11 @@ Test-Suite test-evp-base64     Type:    exitcode-stdio-1.0     Main-Is: Test/OpenSSL/EVP/Base64.hs+    Other-Modules: Test.OpenSSL.TestUtils     Build-Depends:         HsOpenSSL,-        HUnit                >= 1.0 && < 1.5,         base                 >= 4.4 && < 5,-        bytestring           >= 0.9 && < 0.11,-        test-framework       >= 0.8 && < 0.9,-        test-framework-hunit >= 0.3 && < 0.4+        bytestring           >= 0.9 && < 0.11     Default-Language:         Haskell2010     GHC-Options:
Test/OpenSSL/Cipher.hs view
@@ -1,10 +1,9 @@ -- | Tests for the non-EVP ciphers module Main (main) where+ import qualified Data.ByteString as BS import OpenSSL.Cipher-import qualified Test.Framework as TF-import qualified Test.Framework.Providers.HUnit as TF-import Test.HUnit+import Test.OpenSSL.TestUtils  -- | Convert a hex string to a ByteString (e.g. "0011" == BS.pack [0, 0x11]) hexToBS :: String -> BS.ByteString@@ -64,15 +63,12 @@           (hexToBS "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20212223")           (hexToBS "EB6C52821D0BBBF7CE7594462ACA4FAAB407DF866569FD07F48CC0B583D6071F1EC0E6B8") ] -runCtrTest :: CTRTest -> Test-runCtrTest (CTRTest key iv plaintext ciphertext) =-    TestCase $ do-      ctx <- newAESCtx Encrypt key iv-      ct  <- aesCTR ctx plaintext-      assertEqual "" ciphertext ct--tests :: Test-tests = TestList $ map runCtrTest ctrTests+runCtrTest :: CTRTest -> IO ()+runCtrTest (CTRTest key iv plaintext ciphertext) = do+    ctx <- newAESCtx Encrypt key iv+    ct  <- aesCTR ctx plaintext+    assertEqual "" ciphertext ct  main :: IO ()-main = TF.defaultMain $ TF.hUnitTestToTests tests+main =+    mapM_ runCtrTest ctrTests
Test/OpenSSL/DER.hs view
@@ -2,15 +2,10 @@  import OpenSSL.RSA import OpenSSL.DER-import qualified Test.Framework as TF-import qualified Test.Framework.Providers.HUnit as TF-import Test.HUnit--test_encodeDecodeEqual :: Test-test_encodeDecodeEqual = TestCase $ do-  keyPair <- generateRSAKey 1024 3 Nothing-  pubKey <- rsaCopyPublic keyPair-  assertEqual "encodeDecode" (Just pubKey) (fromDERPub (toDERPub keyPair))+import Test.OpenSSL.TestUtils  main :: IO ()-main = TF.defaultMain $ TF.hUnitTestToTests test_encodeDecodeEqual+main = do+    keyPair <- generateRSAKey 1024 3 Nothing+    pubKey <- rsaCopyPublic keyPair+    assertEqual "encodeDecode" (Just pubKey) (fromDERPub (toDERPub keyPair))
Test/OpenSSL/DSA.hs view
@@ -1,14 +1,13 @@ module Main (main) where+ import qualified Data.ByteString as BS import OpenSSL.DSA-import qualified Test.Framework as TF-import qualified Test.Framework.Providers.HUnit as TF-import Test.HUnit+import Test.OpenSSL.TestUtils  -- | This function just runs the example DSA generation, as given in FIP 186-2, --   app 5.-test_generateParameters :: Test-test_generateParameters = TestCase $ do+test_generateParameters :: IO ()+test_generateParameters = do   let seed = BS.pack [0xd5, 0x01, 0x4e, 0x4b,                       0x60, 0xef, 0x2b, 0xa8,                       0xb6, 0x21, 0x1b, 0x40,@@ -25,15 +24,14 @@ testMessage :: BS.ByteString testMessage = BS.pack [1..20] -test_signVerify :: Test-test_signVerify = TestCase $ do+test_signVerify :: IO ()+test_signVerify = do   dsa    <- generateDSAParametersAndKey 512 Nothing   (a, b) <- signDigestedDataWithDSA dsa testMessage   valid  <- verifyDigestedDataWithDSA dsa testMessage (a, b)   assertBool "signVerify" valid -tests :: Test-tests = TestList [test_generateParameters, test_signVerify]- main :: IO ()-main = TF.defaultMain $ TF.hUnitTestToTests tests+main = do+    test_generateParameters+    test_signVerify
Test/OpenSSL/EVP/Base64.hs view
@@ -9,9 +9,7 @@ import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BSL import OpenSSL.EVP.Base64-import qualified Test.Framework as TF-import qualified Test.Framework.Providers.HUnit as TF-import Test.HUnit+import Test.OpenSSL.TestUtils  -- NOTE: bytestring-0.9.0.4 has these instances too, while -- bytestring-0.9.0.3 does not. If our bytestring is 0.9.0.4 we'll@@ -26,10 +24,9 @@   fromString = BSL.fromChunks . map (BS.singleton . fromIntegral . ord) #endif -encodeTests :: Test+encodeTests :: IO () encodeTests =-    TestLabel "encode" $-    TestList $ map (\(a, v) -> encodeBase64BS a ~?= v) pairs+    assertFunction "encodeBase64BS" encodeBase64BS pairs     where       pairs :: [(BS.ByteString, BS.ByteString)]       pairs = [ (""   , ""    )@@ -38,10 +35,9 @@               , ("aaa", "YWFh")               ] -lazyEncodeTests :: Test+lazyEncodeTests :: IO () lazyEncodeTests =-    TestLabel "lazyEncode" $-    TestList $ map (\(a, v) -> encodeBase64LBS a ~?= v) pairs+    assertFunction "encodeBase64LBS" encodeBase64LBS pairs     where       pairs :: [(BSL.ByteString, BSL.ByteString)]       pairs = [ (""   , ""    )@@ -50,10 +46,9 @@               , ("aaa", "YWFh")               ] -decodeTests :: Test+decodeTests :: IO () decodeTests =-    TestLabel "decode" $-    TestList $ map (\(a, v) -> decodeBase64BS a ~?= v) pairs+    assertFunction "decodeBase64BS" decodeBase64BS pairs     where       pairs :: [(BS.ByteString, BS.ByteString)]       pairs = [ (""                  , ""           )@@ -62,12 +57,8 @@               , ("YWJjZGVmZ2hpams=\n", "abcdefghijk")               ] -tests :: Test-tests = TestList-        [ encodeTests-        , lazyEncodeTests-        , decodeTests-        ]- main :: IO ()-main = TF.defaultMain $ TF.hUnitTestToTests tests+main = do+    encodeTests+    lazyEncodeTests+    decodeTests
+ Test/OpenSSL/TestUtils.hs view
@@ -0,0 +1,25 @@+module Test.OpenSSL.TestUtils where++import qualified Control.Exception as E+import Control.Monad++assertBool :: String -> Bool -> IO ()+assertBool n ok =+    unless ok $ E.throw $ E.AssertionFailed $ "Assertion failed: " ++ n++assertEqual :: (Show a, Eq a) => String -> a -> a -> IO ()+assertEqual n a b =+    assertBool (n ++ "\n" ++ show a ++ " /= " ++ show b) (a == b)++assertFunction+    :: (Show x, Show y, Eq y) => String -> (x -> y) -> [(x, y)] -> IO ()+assertFunction n f points =+    forM_ points $ \ (x, y) ->+        let r = f x in+        assertBool+            (n ++ " " ++ showsPrec 11 x "" ++ " == " ++ show r+             ++ " /= " ++ show y)+            (r == y)++--  assertFunction "asdf" (fmap (+1)) [(Just 1, Nothing)]+--  *** Exception: Assertion failed: asdf (Just 1) == Just 2 /= Nothing