Skip to content

Commit

Permalink
Modified 001_basic tap test to verify that the data on disk is encrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
dutow committed Aug 6, 2024
1 parent 7931b29 commit 5f84e8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
17 changes: 15 additions & 2 deletions t/001_basic.pl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
$rt_value = $node->psql('postgres', "SELECT pg_tde_add_key_provider_file('file-vault','/tmp/pg_tde_test_keyring.per');", extra_params => ['-a']);
$rt_value = $node->psql('postgres', "SELECT pg_tde_set_principal_key('test-db-principal-key','file-vault');", extra_params => ['-a']);

$stdout = $node->safe_psql('postgres', 'CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING pg_tde_basic;', extra_params => ['-a']);
$stdout = $node->safe_psql('postgres', 'CREATE TABLE test_enc(id SERIAL,k VARCHAR(32),PRIMARY KEY (id)) USING pg_tde_basic;', extra_params => ['-a']);
PGTDE::append_to_file($stdout);

$stdout = $node->safe_psql('postgres', 'INSERT INTO test_enc (k) VALUES (5),(6);', extra_params => ['-a']);
$stdout = $node->safe_psql('postgres', 'INSERT INTO test_enc (k) VALUES (\'foobar\'),(\'barfoo\');', extra_params => ['-a']);
PGTDE::append_to_file($stdout);

$stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']);
Expand All @@ -62,6 +62,19 @@
$stdout = $node->safe_psql('postgres', 'SELECT * FROM test_enc ORDER BY id ASC;', extra_params => ['-a']);
PGTDE::append_to_file($stdout);

# Verify that we can't see the data in the file
my $tablefile = $node->safe_psql('postgres', 'SHOW data_directory;');
$tablefile .= '/';
$tablefile .= $node->safe_psql('postgres', 'SELECT pg_relation_filepath(\'test_enc\');');

my $strings = 'TABLEFILE FOUND: ';
$strings .= `(ls $tablefile >/dev/null && echo yes) || echo no`;
PGTDE::append_to_file($strings);

$strings = 'CONTAINS FOO (should be empty): ';
$strings .= `strings $tablefile | grep foo`;
PGTDE::append_to_file($strings);

$stdout = $node->safe_psql('postgres', 'DROP TABLE test_enc;', extra_params => ['-a']);
PGTDE::append_to_file($stdout);

Expand Down
15 changes: 9 additions & 6 deletions t/expected/001_basic.out
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
CREATE EXTENSION pg_tde;
-- server restart
CREATE TABLE test_enc(id SERIAL,k INTEGER,PRIMARY KEY (id)) USING pg_tde_basic;
INSERT INTO test_enc (k) VALUES (5),(6);
CREATE TABLE test_enc(id SERIAL,k VARCHAR(32),PRIMARY KEY (id)) USING pg_tde_basic;
INSERT INTO test_enc (k) VALUES ('foobar'),('barfoo');
SELECT * FROM test_enc ORDER BY id ASC;
1|5
2|6
1|foobar
2|barfoo
-- server restart
SELECT * FROM test_enc ORDER BY id ASC;
1|5
2|6
1|foobar
2|barfoo
TABLEFILE FOUND: yes

CONTAINS FOO (should be empty):
DROP TABLE test_enc;
DROP EXTENSION pg_tde;

0 comments on commit 5f84e8c

Please sign in to comment.