Skip to content

Commit

Permalink
add pgjwt tests (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
olirice authored Aug 23, 2024
1 parent 0110bc3 commit 9226af2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
22 changes: 22 additions & 0 deletions nix/tests/expected/pgjwt.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
select
sign(
payload := '{"sub":"1234567890","name":"John Doe","iat":1516239022}',
secret := 'secret',
algorithm := 'HS256'
);
sign
-------------------------------------------------------------------------------------------------------------------------------------------------------------
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o
(1 row)

select
verify(
token := 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRm9vIn0.Q8hKjuadCEhnCPuqIj9bfLhTh_9QSxshTRsA5Aq4IuM',
secret := 'secret',
algorithm := 'HS256'
);
verify
----------------------------------------------------------------
("{""alg"":""HS256"",""typ"":""JWT""}","{""name"":""Foo""}",t)
(1 row)

13 changes: 13 additions & 0 deletions nix/tests/sql/pgjwt.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
select
sign(
payload := '{"sub":"1234567890","name":"John Doe","iat":1516239022}',
secret := 'secret',
algorithm := 'HS256'
);

select
verify(
token := 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiRm9vIn0.Q8hKjuadCEhnCPuqIj9bfLhTh_9QSxshTRsA5Aq4IuM',
secret := 'secret',
algorithm := 'HS256'
);

0 comments on commit 9226af2

Please sign in to comment.