Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

add supautils smoke test #4

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ext/supautils.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ lib, stdenv, fetchFromGitHub, postgresql }:

stdenv.mkDerivation rec {
pname = "supautils";
version = "1.7.3";

buildInputs = [ postgresql ];

src = fetchFromGitHub {
owner = "supabase";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-bkuqF83XRIOl7CuKOh16G7QekPSmt1EdoG0c1W0xFKY=";
};

installPhase = ''
mkdir -p $out/lib

install -D supautils.so -t $out/lib
'';

meta = with lib; {
description = "PostgreSQL extension for enhanced security";
homepage = "https://github.com/supabase/${pname}";
maintainers = with maintainers; [ steve-chavez ];
platforms = postgresql.meta.platforms;
license = licenses.postgresql;
};
}
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@
./ext/hypopg.nix
./ext/pg_tle.nix
./ext/wrappers/default.nix
./ext/supautils.nix
];

makePostgresPkgs = version:
let postgresql = pkgs."postgresql_${version}";
in map (path: pkgs.callPackage path { inherit postgresql; }) ourExtensions;

makePostgresPkgsSet = version:
(builtins.listToAttrs (map (drv:
{ name = drv.pname; value = drv; }
Expand Down
17 changes: 17 additions & 0 deletions tests/smoke/0002-supautils.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
BEGIN;
SELECT plan(2);

-- the setting doesn't exist when supautils is not loaded
SELECT throws_ok($$
select current_setting('supautils.privileged_extensions', false)
$$);

LOAD 'supautils';

-- now it does
SELECT ok(
current_setting('supautils.privileged_extensions', false) = ''
);

SELECT * FROM finish();
ROLLBACK;