Reformatting of some test-cases and removal of superfluous comments.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
module Feature.AsymmetricJwtSpec where
|
module Feature.AsymmetricJwtSpec where
|
||||||
|
|
||||||
-- {{{ Imports
|
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -9,7 +8,6 @@ import Test.Hspec.Wai
|
|||||||
|
|
||||||
import Protolude
|
import Protolude
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
-- }}}
|
|
||||||
|
|
||||||
spec :: SpecWith ((), Application)
|
spec :: SpecWith ((), Application)
|
||||||
spec = describe "server started with asymmetric JWK" $
|
spec = describe "server started with asymmetric JWK" $
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module Feature.AudienceJwtSecretSpec where
|
module Feature.AudienceJwtSecretSpec where
|
||||||
|
|
||||||
-- {{{ Imports
|
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -9,7 +8,6 @@ import Test.Hspec.Wai
|
|||||||
|
|
||||||
import Protolude hiding (get)
|
import Protolude hiding (get)
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
-- }}}
|
|
||||||
|
|
||||||
spec :: SpecWith ((), Application)
|
spec :: SpecWith ((), Application)
|
||||||
spec = describe "test handling of aud claims in JWT" $ do
|
spec = describe "test handling of aud claims in JWT" $ do
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module Feature.BinaryJwtSecretSpec where
|
module Feature.BinaryJwtSecretSpec where
|
||||||
|
|
||||||
-- {{{ Imports
|
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -9,7 +8,6 @@ import Test.Hspec.Wai
|
|||||||
|
|
||||||
import Protolude
|
import Protolude
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
-- }}}
|
|
||||||
|
|
||||||
spec :: SpecWith ((), Application)
|
spec :: SpecWith ((), Application)
|
||||||
spec = describe "server started with binary JWT secret" $
|
spec = describe "server started with binary JWT secret" $
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
module Feature.NoJwtSpec where
|
module Feature.NoJwtSpec where
|
||||||
|
|
||||||
-- {{{ Imports
|
|
||||||
|
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
@@ -9,23 +7,21 @@ import Test.Hspec
|
|||||||
import Test.Hspec.Wai
|
import Test.Hspec.Wai
|
||||||
import Test.Hspec.Wai.JSON
|
import Test.Hspec.Wai.JSON
|
||||||
|
|
||||||
import Protolude
|
import Protolude hiding (get)
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
-- }}}
|
|
||||||
|
|
||||||
spec :: SpecWith ((), Application)
|
spec :: SpecWith ((), Application)
|
||||||
spec = describe "server started without JWT secret" $ do
|
spec = describe "server started without JWT secret" $ do
|
||||||
|
|
||||||
-- this test will stop working 9999999999s after the UNIX EPOCH
|
|
||||||
it "responds with error on attempted auth" $ do
|
it "responds with error on attempted auth" $ do
|
||||||
let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjk5OTk5OTk5OTksInJvbGUiOiJwb3N0Z3Jlc3RfdGVzdF9hdXRob3IiLCJpZCI6Impkb2UifQ.Dpss-QoLYjec5OTsOaAc3FNVsSjA89wACoV-0ra3ClA"
|
-- token body: { "role": "postgrest_test_author" }
|
||||||
request methodGet "/authors_only" [auth] ""
|
let auth = authHeaderJWT "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoicG9zdGdyZXN0X3Rlc3RfYXV0aG9yIn0.Xod-F15qsGL0WhdOCr2j3DdKuTw9QJERVgoFD3vGaWA"
|
||||||
|
request methodGet "/authors_only"
|
||||||
|
[auth]
|
||||||
|
""
|
||||||
`shouldRespondWith`
|
`shouldRespondWith`
|
||||||
[json|{"message":"Server lacks JWT secret"}|]
|
[json|{"message":"Server lacks JWT secret"}|]
|
||||||
{ matchStatus = 500
|
{ matchStatus = 500 }
|
||||||
, matchHeaders = [ matchContentTypeJson ]
|
|
||||||
}
|
|
||||||
|
|
||||||
it "behaves normally when user does not attempt auth" $
|
it "behaves normally when user does not attempt auth" $
|
||||||
request methodGet "/items" [] ""
|
get "/items" `shouldRespondWith` 200
|
||||||
`shouldRespondWith` 200
|
|
||||||
|
|||||||
Reference in New Issue
Block a user