Skip to content

Commit c96389a

Browse files
Merge pull request #126 from 1Password/vzt/e2e-tests-improvements
E2E tests improvements
2 parents 6a721fb + ba38da7 commit c96389a

File tree

12 files changed

+856
-337
lines changed

12 files changed

+856
-337
lines changed

.github/workflows/acceptance-test.yml

Lines changed: 0 additions & 131 deletions
This file was deleted.

.github/workflows/e2e-tests.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: E2E Tests
2+
3+
on:
4+
# For local testing with: act push -W .github/workflows/e2e-tests.yml
5+
push:
6+
branches-ignore:
7+
- "**" # Never runs on GitHub, only locally with act
8+
9+
# For test.yml to call this workflow
10+
workflow_call:
11+
secrets:
12+
OP_CONNECT_CREDENTIALS:
13+
required: true
14+
OP_CONNECT_TOKEN:
15+
required: true
16+
OP_SERVICE_ACCOUNT_TOKEN:
17+
required: true
18+
VAULT:
19+
description: "1Password vault name or UUID"
20+
required: true
21+
22+
jobs:
23+
test-service-account:
24+
name: Service Account (${{ matrix.os }}, ${{ matrix.version }}, export-env=${{ matrix.export-env }})
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
fail-fast: true
28+
matrix:
29+
os: [ubuntu-latest, macos-latest, windows-latest]
30+
version: [latest, 2.30.0]
31+
export-env: [true, false]
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v5
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Generate .env.tpl
39+
shell: bash
40+
run: |
41+
echo "FILE_SECRET=op://${{ secrets.VAULT }}/test-secret/password" > tests/.env.tpl
42+
echo "FILE_SECRET_IN_SECTION=op://${{ secrets.VAULT }}/test-secret/test-section/password" >> tests/.env.tpl
43+
echo "FILE_MULTILINE_SECRET=op://${{ secrets.VAULT }}/multiline-secret/notesPlain" >> tests/.env.tpl
44+
45+
- name: Configure Service account
46+
uses: ./configure
47+
with:
48+
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
49+
50+
- name: Load secrets
51+
id: load_secrets
52+
uses: ./
53+
with:
54+
version: ${{ matrix.version }}
55+
export-env: ${{ matrix.export-env }}
56+
env:
57+
SECRET: op://${{ secrets.VAULT }}/test-secret/password
58+
SECRET_IN_SECTION: op://${{ secrets.VAULT }}/test-secret/test-section/password
59+
MULTILINE_SECRET: op://${{ secrets.VAULT }}/multiline-secret/notesPlain
60+
OP_ENV_FILE: ./tests/.env.tpl
61+
62+
- name: Assert test secret values [step output]
63+
if: ${{ !matrix.export-env }}
64+
shell: bash
65+
env:
66+
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
67+
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
68+
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
69+
FILE_SECRET: ${{ steps.load_secrets.outputs.FILE_SECRET }}
70+
FILE_SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.FILE_SECRET_IN_SECTION }}
71+
FILE_MULTILINE_SECRET: ${{ steps.load_secrets.outputs.FILE_MULTILINE_SECRET }}
72+
run: ./tests/assert-env-set.sh
73+
74+
- name: Assert test secret values [exported env]
75+
if: ${{ matrix.export-env }}
76+
shell: bash
77+
run: ./tests/assert-env-set.sh
78+
79+
- name: Remove secrets [exported env]
80+
if: ${{ matrix.export-env }}
81+
uses: ./
82+
with:
83+
unset-previous: true
84+
85+
- name: Assert removed secrets [exported env]
86+
if: ${{ matrix.export-env }}
87+
shell: bash
88+
run: ./tests/assert-env-unset.sh
89+
90+
test-connect:
91+
name: Connect (ubuntu-latest, ${{ matrix.version }}, export-env=${{ matrix.export-env }})
92+
runs-on: ubuntu-latest
93+
strategy:
94+
fail-fast: true
95+
matrix:
96+
os: [ubuntu-latest, macos-latest, windows-latest]
97+
version: [latest, 2.30.0]
98+
export-env: [true, false]
99+
steps:
100+
- name: Checkout
101+
uses: actions/checkout@v5
102+
with:
103+
fetch-depth: 0
104+
105+
- name: Generate .env.tpl
106+
run: |
107+
mkdir -p tests
108+
echo "FILE_SECRET=op://${{ secrets.VAULT }}/test-secret/password" > tests/.env.tpl
109+
echo "FILE_SECRET_IN_SECTION=op://${{ secrets.VAULT }}/test-secret/test-section/password" >> tests/.env.tpl
110+
echo "FILE_MULTILINE_SECRET=op://${{ secrets.VAULT }}/multiline-secret/notesPlain" >> tests/.env.tpl
111+
112+
- name: Launch 1Password Connect instance
113+
env:
114+
OP_CONNECT_CREDENTIALS: ${{ secrets.OP_CONNECT_CREDENTIALS }}
115+
run: |
116+
echo "$OP_CONNECT_CREDENTIALS" > 1password-credentials.json
117+
docker compose -f tests/fixtures/docker-compose.yml up -d && sleep 10
118+
119+
- name: Configure 1Password Connect
120+
uses: ./configure
121+
with:
122+
connect-host: http://localhost:8080
123+
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
124+
125+
- name: Load secrets
126+
id: load_secrets
127+
uses: ./
128+
with:
129+
version: ${{ matrix.version }}
130+
export-env: ${{ matrix.export-env }}
131+
env:
132+
SECRET: op://${{ secrets.VAULT }}/test-secret/password
133+
SECRET_IN_SECTION: op://${{ secrets.VAULT }}/test-secret/test-section/password
134+
MULTILINE_SECRET: op://${{ secrets.VAULT }}/multiline-secret/notesPlain
135+
OP_ENV_FILE: ./tests/.env.tpl
136+
137+
- name: Assert test secret values [step output]
138+
if: ${{ !matrix.export-env }}
139+
env:
140+
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
141+
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
142+
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
143+
FILE_SECRET: ${{ steps.load_secrets.outputs.FILE_SECRET }}
144+
FILE_SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.FILE_SECRET_IN_SECTION }}
145+
FILE_MULTILINE_SECRET: ${{ steps.load_secrets.outputs.FILE_MULTILINE_SECRET }}
146+
run: ./tests/assert-env-set.sh
147+
148+
- name: Assert test secret values [exported env]
149+
if: ${{ matrix.export-env }}
150+
run: ./tests/assert-env-set.sh
151+
152+
- name: Remove secrets [exported env]
153+
if: ${{ matrix.export-env }}
154+
uses: ./
155+
with:
156+
unset-previous: true
157+
158+
- name: Assert removed secrets [exported env]
159+
if: ${{ matrix.export-env }}
160+
run: ./tests/assert-env-unset.sh
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1+
name: Lint and Test
2+
13
on:
24
push:
35
branches: [main]
46
pull_request:
5-
name: Lint
67

78
jobs:
8-
lint:
9+
lint-and-test:
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: actions/checkout@v3
12+
- uses: actions/checkout@v5
13+
1214
- name: Run ShellCheck
1315
uses: ludeeus/action-shellcheck@2.0.0
1416
with:
1517
ignore_paths: >-
1618
.husky
19+
1720
- name: Setup Node.js
18-
id: setup-node
1921
uses: actions/setup-node@v4
2022
with:
2123
node-version: 20
2224
cache: npm
23-
- name: Install Dependencies
24-
id: install
25+
26+
- name: Install dependencies
2527
run: npm ci
28+
2629
- name: Check formatting
2730
run: npm run format:check
31+
2832
- name: Check lint
2933
run: npm run lint
34+
35+
- name: Run unit tests
36+
run: npm test

.github/workflows/ok-to-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# If someone with write access comments "/ok-to-test" on a pull request, emit a repository_dispatch event
1+
# Write comments "/ok-to-test sha=<hash>" on a pull request. This will emit a repository_dispatch event.
22
name: Ok To Test
33

44
on:
@@ -15,7 +15,7 @@ jobs:
1515
if: ${{ github.event.issue.pull_request }}
1616
steps:
1717
- name: Slash Command Dispatch
18-
uses: peter-evans/slash-command-dispatch@v3
18+
uses: peter-evans/slash-command-dispatch@v5
1919
with:
2020
token: ${{ secrets.GITHUB_TOKEN }}
2121
reaction-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)