Skip to content

Commit b924d95

Browse files
authored
Merge pull request #20 from cipherstash/chore/add-postgres-tests
Chore: add Postgres integration tests
2 parents 620b732 + 5b69343 commit b924d95

File tree

8 files changed

+518
-10
lines changed

8 files changed

+518
-10
lines changed

.github/workflows/test.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ jobs:
5252
tests:
5353
name: Tests
5454
runs-on: ubuntu-latest
55+
env:
56+
CS_WORKSPACE_ID: ${{ secrets.CS_WORKSPACE_ID }}
57+
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
58+
CS_CLIENT_ID: ${{ secrets.CS_CLIENT_ID }}
59+
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
60+
PGPORT: 5432
61+
PGDATABASE: cipherstash
62+
PGUSER: cipherstash
63+
PGPASSWORD: password
64+
PGHOST: localhost
5565
steps:
5666
- name: Checkout Code
5767
uses: actions/checkout@v3
@@ -69,11 +79,12 @@ jobs:
6979
- name: Install integration test dependencies
7080
run: npm ci
7181
working-directory: ./integration-tests
82+
- name: Set up integration test DB
83+
run: |
84+
docker compose up --detach --wait
85+
npm run eql:download
86+
npm run eql:install
87+
working-directory: ./integration-tests
7288
- name: Test (integration)
73-
env:
74-
CS_WORKSPACE_ID: ${{ secrets.CS_WORKSPACE_ID }}
75-
CS_CLIENT_ACCESS_KEY: ${{ secrets.CS_CLIENT_ACCESS_KEY }}
76-
CS_CLIENT_ID: ${{ secrets.CS_CLIENT_ID }}
77-
CS_CLIENT_KEY: ${{ secrets.CS_CLIENT_KEY }}
7889
run: npm test
7990
working-directory: ./integration-tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ cargo.log
88
cross.log
99
mise.local.toml
1010
cipherstash.secret.toml
11+
cipherstash-*.sql

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,20 +124,31 @@ protect-ffi/
124124
Integration tests live in the `./integration-tests` directory.
125125
These tests use the local build of Rust and JavaScript artifacts to test `@cipherstash/protect-ffi` as API consumers would.
126126

127-
These tests rely on CipherStash to be configured (via `.toml` config or environment variables).
127+
These tests rely on:
128128

129-
Example environment variables to set:
129+
- CipherStash to be configured (via `.toml` config or environment variables), and
130+
- Environment variables for Postgres to be set
131+
132+
Example environment variables:
130133
```
131134
CS_CLIENT_ID=
132135
CS_CLIENT_KEY=
133136
CS_CLIENT_ACCESS_KEY=
134137
CS_WORKSPACE_ID=
138+
PGPORT=5432
139+
PGDATABASE=cipherstash
140+
PGUSER=cipherstash
141+
PGPASSWORD=password
142+
PGHOST=localhost
135143
```
136144

137145
To run integration tests:
138146
```
139147
npm run debug
140148
cd integration-tests
149+
docker compose up --detach --wait
150+
npm run eql:download
151+
npm run eql:install
141152
npm run test
142153
```
143154

integration-tests/docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
postgres:
3+
image: postgres:latest
4+
container_name: protect-ffi-postgres
5+
environment:
6+
- POSTGRES_DB=${PGDATABASE:-cipherstash}
7+
- POSTGRES_USER=${PGUSER:-cipherstash}
8+
- POSTGRES_PASSWORD=${PGPASSWORD:-password}
9+
ports:
10+
- 5432:5432
11+
restart: always
12+
healthcheck:
13+
test: [ "CMD-SHELL", "pg_isready" ]
14+
interval: 1s
15+
timeout: 5s
16+
retries: 10

0 commit comments

Comments
 (0)