mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-10 11:34:55 +02:00
Merge 9b028535bd into 1dcbb2dbc1
This commit is contained in:
commit
debfba03da
43
test/SpecHelper.hs
Normal file
43
test/SpecHelper.hs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
|
module SpecHelper
|
||||||
|
( App(..)
|
||||||
|
, Widget
|
||||||
|
, resourcesApp
|
||||||
|
, module Test.Hspec
|
||||||
|
, module Yesod
|
||||||
|
, module Yesod.Auth
|
||||||
|
, module Yesod.Auth.OAuth2
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Test.Hspec
|
||||||
|
|
||||||
|
import Data.Text (Text)
|
||||||
|
|
||||||
|
import Yesod
|
||||||
|
import Yesod.Auth
|
||||||
|
import Yesod.Auth.OAuth2
|
||||||
|
|
||||||
|
data App = App
|
||||||
|
|
||||||
|
mkYesod "App" [parseRoutes| / R GET |]
|
||||||
|
|
||||||
|
instance Yesod App
|
||||||
|
instance YesodAuth App where
|
||||||
|
type AuthId App = Text
|
||||||
|
|
||||||
|
authHttpManager = undefined
|
||||||
|
authPlugins = undefined
|
||||||
|
authenticate = undefined
|
||||||
|
loginDest = undefined
|
||||||
|
logoutDest = undefined
|
||||||
|
maybeAuthId = undefined
|
||||||
|
|
||||||
|
instance RenderMessage App FormMessage where
|
||||||
|
renderMessage _ _ = defaultFormMessage
|
||||||
|
|
||||||
|
getR :: Handler ()
|
||||||
|
getR = return ()
|
||||||
@ -3,13 +3,38 @@ module Yesod.Auth.OAuth2Spec
|
|||||||
, spec
|
, spec
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Test.Hspec
|
import SpecHelper
|
||||||
import Yesod.Auth.OAuth2
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspec spec
|
main = hspec spec
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = describe "authOAuth2" $
|
spec = describe "authOAuth2" $
|
||||||
it "works" $
|
it "works" $ do
|
||||||
|
-- If I could somehow get this dispatch to execute, I could assert on the
|
||||||
|
-- response; at least enough to verify the state parameter that prompted
|
||||||
|
-- this track of work...
|
||||||
|
--
|
||||||
|
-- Currently, the blocker is that apDispatch is:
|
||||||
|
--
|
||||||
|
-- > HandlerT Auth (HandlerT App IO) TypedContent
|
||||||
|
--
|
||||||
|
-- but I really need a:
|
||||||
|
--
|
||||||
|
-- > HandlerT App IO TypedContent
|
||||||
|
--
|
||||||
|
-- to be able to use runFakeHandler, as is sort of shown below:
|
||||||
|
--
|
||||||
|
-- > let app = App
|
||||||
|
-- > plugin = authOAuth2 "example" undefined undefined
|
||||||
|
-- >
|
||||||
|
-- > x <- runFakeHandler
|
||||||
|
-- > M.empty undefined (getAuth app) $
|
||||||
|
-- > apDispatch plugin "GET" ["callback"]
|
||||||
|
-- >
|
||||||
|
-- > liftIO $ print (x :: TypedContent)
|
||||||
|
--
|
||||||
|
-- I basically need to peel one layer off the transformer stack, but I can't
|
||||||
|
-- find the right run-handler anywhere.
|
||||||
|
|
||||||
True `shouldBe` True
|
True `shouldBe` True
|
||||||
|
|||||||
@ -83,6 +83,9 @@ test-suite test
|
|||||||
build-depends: base
|
build-depends: base
|
||||||
, yesod-auth-oauth2
|
, yesod-auth-oauth2
|
||||||
, hspec
|
, hspec
|
||||||
|
, text
|
||||||
|
, yesod
|
||||||
|
, yesod-auth
|
||||||
|
|
||||||
source-repository head
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user