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