Isolate tests

Credentials from AuthSpec were interfering with StructureSpec
This commit is contained in:
Joe Nelson
2015-01-31 11:32:08 -08:00
parent 88af46fbe3
commit f06f3e3394
2 changed files with 19 additions and 13 deletions
+7 -1
View File
@@ -11,13 +11,19 @@ import SpecHelper
-- }}} -- }}}
spec :: Spec spec :: Spec
spec = around withApp $ describe "authorization" $ do spec = beforeAll
(clearTable "postgrest.auth") . afterAll_ (clearTable "postgrest.auth")
$ around withApp
$ describe "authorization" $ do
it "hides tables that anonymous does not own" $ it "hides tables that anonymous does not own" $
get "/authors_only" `shouldRespondWith` 404 get "/authors_only" `shouldRespondWith` 404
it "indicates login failure" $ do it "indicates login failure" $ do
let auth = authHeader "postgrest_test_author" "fakefake" let auth = authHeader "postgrest_test_author" "fakefake"
request methodGet "/authors_only" [auth] "" request methodGet "/authors_only" [auth] ""
`shouldRespondWith` 401 `shouldRespondWith` 401
it "allows users with permissions to see their tables" $ do it "allows users with permissions to see their tables" $ do
_ <- post "/postgrest/users" [json| { "id":"jdoe", "pass": "1234", "role": "postgrest_test_author" } |] _ <- post "/postgrest/users" [json| { "id":"jdoe", "pass": "1234", "role": "postgrest_test_author" } |]
let auth = authHeader "jdoe" "1234" let auth = authHeader "jdoe" "1234"
+1 -1
View File
@@ -19,7 +19,7 @@ import TestTypes(IncPK(..), CompoundPK(..))
--import Debug.Trace --import Debug.Trace
spec :: Spec spec :: Spec
spec = around withApp $ do spec = afterAll_ resetDb $ around withApp $ do
describe "Posting new record" $ do describe "Posting new record" $ do
after_ (clearTable "menagerie") . it "accepts disparate json types" $ do after_ (clearTable "menagerie") . it "accepts disparate json types" $ do
p <- post "/menagerie" p <- post "/menagerie"