diff --git a/test/Feature/StructureSpec.hs b/test/Feature/StructureSpec.hs index f27a7e046..d9393dac9 100644 --- a/test/Feature/StructureSpec.hs +++ b/test/Feature/StructureSpec.hs @@ -11,12 +11,9 @@ import Network.HTTP.Types spec :: Spec spec = before resetDb $ around withApp $ do - describe "GET /" $ - it "lists views in schema" $ do - _ <- post "/dbapi/users" [json| { "id":"jdoe", "pass": "1234", "role": "dbapi_test_author" } |] - let auth = authHeader "jdoe" "1234" - - request methodGet "/" [auth] "" + describe "GET /" $ do + it "lists views in schema" $ + request methodGet "/" [] "" `shouldRespondWith` [json| [ {"schema":"1","name":"auto_incrementing_pk","insertable":true} , {"schema":"1","name":"compound_pk","insertable":true} @@ -28,6 +25,17 @@ spec = before resetDb $ around withApp $ do ] |] {matchStatus = 200} + it "lists only views user has permission to see" $ do + _ <- post "/dbapi/users" [json| { "id":"jdoe", "pass": "1234", "role": "dbapi_test_author" } |] + let auth = authHeader "jdoe" "1234" + + request methodGet "/" [auth] "" + `shouldRespondWith` [json| [ + {"schema":"1","name":"authors_only","insertable":true} + ] |] + {matchStatus = 200} + + describe "Table info" $ do it "is available with OPTIONS verb" $ request methodOptions "/menagerie" [] "" `shouldRespondWith` diff --git a/test/fixtures/schema.sql b/test/fixtures/schema.sql index 556fdf802..44a90c2aa 100755 --- a/test/fixtures/schema.sql +++ b/test/fixtures/schema.sql @@ -741,6 +741,11 @@ GRANT ALL ON TABLE compound_pk TO dbapi_test; GRANT ALL ON TABLE compound_pk TO dbapi_anonymous; +REVOKE ALL ON TABLE has_fk FROM PUBLIC; +REVOKE ALL ON TABLE has_fk FROM dbapi_test; +GRANT ALL ON TABLE has_fk TO dbapi_test; +GRANT ALL ON TABLE has_fk TO dbapi_anonymous; + -- -- TOC entry 2328 (class 0 OID 0) -- Dependencies: 197