SizeLimitExceeded isn't either

This commit is contained in:
Matvey Aksenov 2015-03-28 10:37:16 +00:00
parent 2013999e24
commit 86f256fbd8
2 changed files with 22 additions and 9 deletions

View File

@ -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))

View File

@ -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 ()