Problem after exceptions when authed

Reproduces #264
This commit is contained in:
Joe Nelson
2015-08-26 20:49:23 -07:00
parent 9b01d1b1ab
commit 480800edbd
2 changed files with 25 additions and 5 deletions
+7
View File
@@ -29,6 +29,13 @@ spec = beforeAll
request methodGet "/authors_only" [auth] "" request methodGet "/authors_only" [auth] ""
`shouldRespondWith` 200 `shouldRespondWith` 200
it "recovers after 400 error with logged in user" $ do
_ <- post "/postgrest/users" [json| { "id":"jdoe", "pass": "1234", "role": "postgrest_test_author" } |]
let auth = authHeaderBasic "jdoe" "1234"
_ <- request methodPost "/rpc/problem" [auth] ""
request methodGet "/authors_only" [auth] ""
`shouldRespondWith` 200
it "allows users to login (JWT)" $ do it "allows users to login (JWT)" $ 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" } |]
post "/postgrest/tokens" [json| { "id":"jdoe", "pass": "1234" } |] post "/postgrest/tokens" [json| { "id":"jdoe", "pass": "1234" } |]
+13
View File
@@ -228,6 +228,14 @@ CREATE FUNCTION "1".sayhello(name text) RETURNS text AS $$
$$ LANGUAGE SQL; $$ LANGUAGE SQL;
CREATE FUNCTION "1".problem() RETURNS void LANGUAGE plpgsql AS
$$
BEGIN
RAISE 'bad thing';
END;
$$;
CREATE TABLE menagerie ( CREATE TABLE menagerie (
"integer" integer NOT NULL, "integer" integer NOT NULL,
double double precision NOT NULL, double double precision NOT NULL,
@@ -544,6 +552,11 @@ GRANT EXECUTE ON FUNCTION sayhello(text) TO postgrest_test;
GRANT EXECUTE ON FUNCTION sayhello(text) TO postgrest_anonymous; GRANT EXECUTE ON FUNCTION sayhello(text) TO postgrest_anonymous;
REVOKE ALL ON FUNCTION problem() FROM PUBLIC;
REVOKE ALL ON FUNCTION problem() FROM postgrest_test_author;
GRANT EXECUTE ON FUNCTION problem() TO postgrest_test_author;
REVOKE ALL ON SEQUENCE items_id_seq FROM PUBLIC; REVOKE ALL ON SEQUENCE items_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE items_id_seq FROM postgrest_test; REVOKE ALL ON SEQUENCE items_id_seq FROM postgrest_test;
GRANT ALL ON SEQUENCE items_id_seq TO postgrest_test; GRANT ALL ON SEQUENCE items_id_seq TO postgrest_test;