From a154a2d1ec3fe1f6b3d971a4cb811164117259e5 Mon Sep 17 00:00:00 2001 From: aaron levin Date: Fri, 25 Dec 2015 12:45:10 +0100 Subject: [PATCH] get servant-mock building with new GADT-based auth --- servant-mock/src/Servant/Mock.hs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/servant-mock/src/Servant/Mock.hs b/servant-mock/src/Servant/Mock.hs index b2f7804e..3e7e1306 100644 --- a/servant-mock/src/Servant/Mock.hs +++ b/servant-mock/src/Servant/Mock.hs @@ -143,21 +143,24 @@ instance (KnownSymbol s, HasMock rest) => HasMock (QueryFlag s :> rest) where instance (KnownSymbol h, FromHttpApiData a, HasMock rest) => HasMock (Header h a :> rest) where mock _ = \_ -> mock (Proxy :: Proxy rest) -instance (HasMock rest, AuthData authdata, Arbitrary usr) - => HasMock (AuthProtect authdata (usr :: *) 'Lax :> rest) where - mock _ = laxProtect (\_ -> do { a <- generate arbitrary; return (Just a)}) - (\_ -> mock (Proxy :: Proxy rest)) +instance ( HasMock rest + , AuthData authData mError + , Arbitrary usr + ) + => HasMock (AuthProtect authData (usr :: *) 'Lax mError 'Lax uError :> rest) where + mock _ = authProtect LaxMissing + LaxUnauthenticated + (\_ -> do { a <- generate arbitrary; return (Right a) }) + (\_ -> mock (Proxy :: Proxy rest)) instance (HasMock rest, Arbitrary usr, KnownSymbol realm) - => HasMock (AuthProtect (BasicAuth realm) (usr :: *) 'Strict :> rest) where + => HasMock (AuthProtect (BasicAuth realm) (usr :: *) 'Strict () 'Strict () :> rest) where mock _ = basicAuthStrict (\_ -> do { a <- generate arbitrary; return (Just a)}) (\_ -> mock (Proxy :: Proxy rest)) -instance (HasMock rest, Arbitrary usr) - => HasMock (AuthProtect JWTAuth (usr :: *) 'Strict :> rest) where - mock _ = strictProtect (\_ -> do { a <- generate arbitrary; return (Just a)}) - jwtAuthHandlers - (\_ -> mock (Proxy :: Proxy rest)) +instance (HasMock rest) + => HasMock (AuthProtect JWTAuth (JWT VerifiedJWT) 'Strict () 'Strict () :> rest) where + mock _ = jwtAuthStrict (secret "secret") (\_ -> mock (Proxy :: Proxy rest)) instance (Arbitrary a, AllCTRender ctypes a) => HasMock (Delete ctypes a) where mock _ = mockArbitrary