summaryrefslogtreecommitdiffstats
path: root/nixos/tests
diff options
context:
space:
mode:
authorTomasz Czyż <tomasz.czyz@gmail.com>2017-02-26 10:14:32 +0000
committerFranz Pletz <fpletz@fnordicwalking.de>2017-02-26 11:14:32 +0100
commit0b27c74eb2517d307b1c1bbd04567157fba7cb63 (patch)
tree2a98a44dd08b5e1f340ffb99bea61e8595336789 /nixos/tests
parent488ece816949bbb92462071255c1c56cdbd74ae2 (diff)
pgjwt: init at 0.0.1 (#22644)
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/pgjwt.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/tests/pgjwt.nix b/nixos/tests/pgjwt.nix
new file mode 100644
index 000000000000..2cf2963ae316
--- /dev/null
+++ b/nixos/tests/pgjwt.nix
@@ -0,0 +1,42 @@
+import ./make-test.nix ({ pkgs, ...} :
+let
+ test = pkgs.writeText "test.sql" ''
+ CREATE EXTENSION pgcrypto;
+ CREATE EXTENSION pgjwt;
+ select sign('{"sub":"1234567890","name":"John Doe","admin":true}', 'secret');
+ select * from verify('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ', 'secret');
+ '';
+in
+{
+ name = "pgjwt";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ spinus ];
+ };
+
+ nodes = {
+ master =
+ { pkgs, config, ... }:
+
+ {
+ services.postgresql = let mypg = pkgs.postgresql95; in {
+ enable = true;
+ package = mypg;
+ extraPlugins =[pkgs.pgjwt];
+ initialScript = pkgs.writeText "postgresql-init.sql"
+ ''
+ CREATE ROLE postgres WITH superuser login createdb;
+ '';
+ };
+ };
+ };
+
+ testScript = ''
+ startAll;
+ $master->waitForUnit("postgresql");
+ $master->succeed("timeout 10 bash -c 'while ! psql postgres -c \"SELECT 1;\";do sleep 1;done;'");
+ $master->succeed("cat ${test} | psql postgres");
+ # I can't make original test working :[
+ # $master->succeed("${pkgs.perlPackages.TAPParserSourceHandlerpgTAP}/bin/pg_prove -d postgres ${pkgs.pgjwt.src}/test.sql");
+
+ '';
+})