@@ -546,16 +546,16 @@ type BasicAuthAPI = BasicAuth "foo" () :> "basic" :> Get '[JSON] Animal
546546
547547basicAuthApi :: Proxy BasicAuthAPI
548548basicAuthApi = Proxy
549+
549550basicAuthServer :: Server BasicAuthAPI
550551basicAuthServer = const (return jerry)
551552
552553basicAuthContext :: Context '[ BasicAuthCheck () ]
553554basicAuthContext =
554− let basicHandler = BasicAuthCheck $ (\(BasicAuthData usr pass) ->
555+ let basicHandler = BasicAuthCheck $ \(BasicAuthData usr pass) ->
555556 if usr == "servant" && pass == "server"
556− then return (Authorized ())
557− else return Unauthorized
558− )
557+ then return (Authorized ())
558+ else return Unauthorized
559559 in basicHandler :. EmptyContext
560560
561561basicAuthSpec :: Spec
@@ -564,10 +564,13 @@ basicAuthSpec = do
564564 with (return (serveWithContext basicAuthApi basicAuthContext basicAuthServer)) $ do
565565
566566 context "Basic Authentication" $ do
567− it "returns with 401 with bad password" $ do
567+ it "returns 401 with bad password" $ do
568568 get "/basic" `shouldRespondWith` 401
569+
569570 it "returns 200 with the right password" $ do
570− THW.request methodGet "/basic" [("Authorization","Basic c2VydmFudDpzZXJ2ZXI=")] "" `shouldRespondWith` 200
571+ let validCredentials = [("Authorization", "Basic c2VydmFudDpzZXJ2ZXI=")]
572+ THW.request methodGet "/basic" validCredentials ""
573+ `shouldRespondWith` 200
571574
572575-- }}}
573576------------------------------------------------------------------------------
@@ -575,14 +578,16 @@ basicAuthSpec = do
575578------------------------------------------------------------------------------
576579
577580type GenAuthAPI = AuthProtect "auth" :> "auth" :> Get '[JSON] Animal
581+
578582authApi :: Proxy GenAuthAPI
579583authApi = Proxy
584+
580585authServer :: Server GenAuthAPI
581586authServer = const (return tweety)
582587
583588type instance AuthServerData (AuthProtect "auth") = ()
584589
585−genAuthContext :: Context '[ AuthHandler Request () ]
590+genAuthContext :: Context '[AuthHandler Request ()]
586591genAuthContext =
587592 let authHandler = (\req ->
588593 if elem ("Auth", "secret") (requestHeaders req)
@@ -599,6 +604,7 @@ genAuthSpec = do
599604 context "Custom Auth Protection" $ do
600605 it "returns 401 when missing headers" $ do
601606 get "/auth" `shouldRespondWith` 401
607+
602608 it "returns 200 with the right header" $ do
603609 THW.request methodGet "/auth" [("Auth","secret")] "" `shouldRespondWith` 200
604610