Skip to content

Commit b978a2e

Browse files
authored
add pgjwt tests (supabase#1161)
1 parent 826c86c commit b978a2e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

nix/tests/expected/pgjwt.out

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
select
2+
sign(
3+
payload := '{"sub":"1234567890","name":"John Doe","iat":1516239022}',
4+
secret := 'secret',
5+
algorithm := 'HS256'
6+
);
7+
sign
8+
-------------------------------------------------------------------------------------------------------------------------------------------------------------
9+
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o
10+
(1 row)
11+
12+
select
13+
verify(
14+
token := 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRm9vIn0.Q8hKjuadCEhnCPuqIj9bfLhTh_9QSxshTRsA5Aq4IuM',
15+
secret := 'secret',
16+
algorithm := 'HS256'
17+
);
18+
verify
19+
----------------------------------------------------------------
20+
("{""alg"":""HS256"",""typ"":""JWT""}","{""name"":""Foo""}",t)
21+
(1 row)
22+

nix/tests/sql/pgjwt.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
select
2+
sign(
3+
payload := '{"sub":"1234567890","name":"John Doe","iat":1516239022}',
4+
secret := 'secret',
5+
algorithm := 'HS256'
6+
);
7+
8+
select
9+
verify(
10+
token := 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRm9vIn0.Q8hKjuadCEhnCPuqIj9bfLhTh_9QSxshTRsA5Aq4IuM',
11+
secret := 'secret',
12+
algorithm := 'HS256'
13+
);

0 commit comments

Comments
 (0)