add example for more complicated api
This commit is contained in:
parent
4f4ca69672
commit
05e140314e
1 changed files with 16 additions and 0 deletions
|
@ -211,6 +211,15 @@ type GenAuthAPI =
|
||||||
genAuthAPI :: Proxy GenAuthAPI
|
genAuthAPI :: Proxy GenAuthAPI
|
||||||
genAuthAPI = Proxy
|
genAuthAPI = Proxy
|
||||||
|
|
||||||
|
type GenAuthAPI2 =
|
||||||
|
AuthProtect "auth-tag" :> ("private" :> "auth" :> Get '[JSON] Person
|
||||||
|
:<|> ("private2" :> "auth" :> Get '[JSON] Person))
|
||||||
|
|
||||||
|
|
||||||
|
genAuthAPI2 :: Proxy GenAuthAPI2
|
||||||
|
genAuthAPI2 = Proxy
|
||||||
|
|
||||||
|
|
||||||
type instance AuthServerData (AuthProtect "auth-tag") = ()
|
type instance AuthServerData (AuthProtect "auth-tag") = ()
|
||||||
type instance AuthClientData (AuthProtect "auth-tag") = ()
|
type instance AuthClientData (AuthProtect "auth-tag") = ()
|
||||||
|
|
||||||
|
@ -385,6 +394,13 @@ genAuthSpec = beforeAll (startWaiApp genAuthServer) $ afterAll endWaiApp $ do
|
||||||
let authRequest = mkAuthenticateReq () (\_ req -> SCR.addHeader "AuthHeader" ("cool" :: String) req)
|
let authRequest = mkAuthenticateReq () (\_ req -> SCR.addHeader "AuthHeader" ("cool" :: String) req)
|
||||||
(left show <$> runExceptT (getProtected authRequest manager baseUrl)) `shouldReturn` Right alice
|
(left show <$> runExceptT (getProtected authRequest manager baseUrl)) `shouldReturn` Right alice
|
||||||
|
|
||||||
|
it "Also works for more complicated apis" $ \(_, baseUrl) -> do
|
||||||
|
let (getProtected :<|> getOtherProtected) = client genAuthAPI2
|
||||||
|
let authRequest = mkAuthenticateReq () (\_ req -> SCR.addHeader "AuthHeader" ("cool" :: String) req)
|
||||||
|
(left show <$> runExceptT (getProtected authRequest manager baseUrl)) `shouldReturn` Right alice
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context "Authentication is rejected when requests are not authenticated properly" $ do
|
context "Authentication is rejected when requests are not authenticated properly" $ do
|
||||||
|
|
||||||
it "Authenticates a AuthProtect protected server appropriately" $ \(_, baseUrl) -> do
|
it "Authenticates a AuthProtect protected server appropriately" $ \(_, baseUrl) -> do
|
||||||
|
|
Loading…
Reference in a new issue