From 86f256fbd8ec494c1775bee5c91403e257f27087 Mon Sep 17 00:00:00 2001 From: Matvey Aksenov Date: Sat, 28 Mar 2015 10:37:16 +0000 Subject: [PATCH] SizeLimitExceeded isn't either --- src/Ldap/Client.hs | 1 + test/Ldap/ClientSpec.hs | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Ldap/Client.hs b/src/Ldap/Client.hs index 1f4b4b5..399d72b 100644 --- a/src/Ldap/Client.hs +++ b/src/Ldap/Client.hs @@ -286,6 +286,7 @@ searchResult :: Response -> Either SearchError [SearchEntry] searchResult (Type.SearchResultDone (Type.LdapResult code _ _ _) :| xs) | Type.Success <- code = Right (mapMaybe g xs) | Type.AdminLimitExceeded <- code = Right (mapMaybe g xs) + | Type.SizeLimitExceeded <- code = Right (mapMaybe g xs) | otherwise = Left (SearchErrorCode code) where g (Type.SearchResultEntry (Type.LdapDn (Type.LdapString dn)) diff --git a/test/Ldap/ClientSpec.hs b/test/Ldap/ClientSpec.hs index c58dafa..58297dd 100644 --- a/test/Ldap/ClientSpec.hs +++ b/test/Ldap/ClientSpec.hs @@ -10,12 +10,24 @@ import qualified Ldap.Client as Ldap spec :: Spec spec = - context "Example stolen from the LDAP package tests" $ - it "searches the public LDAP server at MIT" $ do - res <- Ldap.with (Plain "scripts.mit.edu") 389 $ \l -> do - res <- Ldap.search l (Dn "ou=People,dc=scripts,dc=mit,dc=edu") - (scope WholeSubtree <> typesOnly True) - (Present (Attr "uid")) - [] - res `shouldSatisfy` (not . null) - res `shouldBe` Right () + context "Examples stolen from the LDAP package tests" $ + + context "public LDAP server at MIT" $ do + + it "searches the whole tree for the entries that have ‘uid’ attribute" $ do + res <- Ldap.with (Plain "scripts.mit.edu") 389 $ \l -> do + res <- Ldap.search l (Dn "ou=People,dc=scripts,dc=mit,dc=edu") + (scope WholeSubtree <> typesOnly True) + (Present (Attr "uid")) + [] + res `shouldSatisfy` (not . null) + res `shouldBe` Right () + + it "searches the single level for the first 10 entries that have ‘uid’ attribute" $ do + res <- Ldap.with (Plain "scripts.mit.edu") 389 $ \l -> do + res <- Ldap.search l (Dn "ou=People,dc=scripts,dc=mit,dc=edu") + (scope WholeSubtree <> typesOnly True <> size 10) + (Present (Attr "uid")) + [] + length res `shouldBe` 10 + res `shouldBe` Right ()