Merge pull request #446 from haskell-servant/gen-auth-test-for-raw
Add test: Gen Auth properly supports Raw endpoints
This commit is contained in:
commit
56c13eeae9
1 changed files with 10 additions and 5 deletions
|
@ -593,12 +593,14 @@ basicAuthSpec = do
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
type GenAuthAPI = AuthProtect "auth" :> "auth" :> Get '[JSON] Animal
|
type GenAuthAPI = AuthProtect "auth" :> "auth" :> Get '[JSON] Animal
|
||||||
|
:<|> Raw
|
||||||
|
|
||||||
authApi :: Proxy GenAuthAPI
|
genAuthApi :: Proxy GenAuthAPI
|
||||||
authApi = Proxy
|
genAuthApi = Proxy
|
||||||
|
|
||||||
authServer :: Server GenAuthAPI
|
genAuthServer :: Server GenAuthAPI
|
||||||
authServer = const (return tweety)
|
genAuthServer = const (return tweety)
|
||||||
|
:<|> (\ _ respond -> respond $ responseLBS imATeaPot418 [] "")
|
||||||
|
|
||||||
type instance AuthServerData (AuthProtect "auth") = ()
|
type instance AuthServerData (AuthProtect "auth") = ()
|
||||||
|
|
||||||
|
@ -614,7 +616,7 @@ genAuthContext =
|
||||||
genAuthSpec :: Spec
|
genAuthSpec :: Spec
|
||||||
genAuthSpec = do
|
genAuthSpec = do
|
||||||
describe "Servant.API.Auth" $ do
|
describe "Servant.API.Auth" $ do
|
||||||
with (return (serveWithContext authApi genAuthContext authServer)) $ do
|
with (return (serveWithContext genAuthApi genAuthContext genAuthServer)) $ do
|
||||||
|
|
||||||
context "Custom Auth Protection" $ do
|
context "Custom Auth Protection" $ do
|
||||||
it "returns 401 when missing headers" $ do
|
it "returns 401 when missing headers" $ do
|
||||||
|
@ -623,6 +625,9 @@ genAuthSpec = do
|
||||||
it "returns 200 with the right header" $ do
|
it "returns 200 with the right header" $ do
|
||||||
THW.request methodGet "/auth" [("Auth","secret")] "" `shouldRespondWith` 200
|
THW.request methodGet "/auth" [("Auth","secret")] "" `shouldRespondWith` 200
|
||||||
|
|
||||||
|
it "plays nice with subsequent Raw endpoints" $ do
|
||||||
|
get "/foo" `shouldRespondWith` 418
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
-- * Test data types {{{
|
-- * Test data types {{{
|
||||||
|
|
Loading…
Reference in a new issue