Skip to content

Commit c21917c

Browse files
authored
test: add integration test for get and create (#12)
1 parent a3c3e67 commit c21917c

File tree

5 files changed

+183
-0
lines changed

5 files changed

+183
-0
lines changed

.github/workflows/test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Test module
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: master
7+
8+
jobs:
9+
integration-test:
10+
environment: test
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: 3.x
21+
22+
- name: Install Python dependencies
23+
run: |
24+
pip install ansible
25+
pip install requests
26+
python -m pip install --upgrade pip
27+
pip list
28+
29+
- name: Build
30+
id: build
31+
run: |
32+
OUTPUT=$(ansible-galaxy collection build)
33+
echo "$OUTPUT"
34+
COLLECTION_PATH=$(echo "$OUTPUT" | grep -o '/[^ ]*\.tar\.gz')
35+
echo "collection_path=$COLLECTION_PATH" >> $GITHUB_OUTPUT
36+
echo "Collection path: $COLLECTION_PATH"
37+
38+
- name: Install collection
39+
run: ansible-galaxy collection install ${{ steps.build.outputs.collection_path }} --force
40+
working-directory: tests/integration
41+
42+
- name: Run get-vaults
43+
run: ansible-playbook test_get_vault.yml
44+
working-directory: tests/integration
45+
env:
46+
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
47+
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
48+
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
49+
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}
50+
51+
- name: Run get-secrets
52+
run: ansible-playbook test_get_secret.yml
53+
working-directory: tests/integration
54+
env:
55+
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
56+
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
57+
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
58+
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}
59+
60+
- name: Run create-secrets
61+
run: ansible-playbook test_create_secret.yml
62+
working-directory: tests/integration
63+
env:
64+
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
65+
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
66+
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
67+
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}

tests/integration/secrets.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
secrets:
2+
- secret_name: "secret"
3+
- secret_id: "890cbb54-7078-4d0c-925f-e89a33ee3e46"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
- name: Fetch DVLS
3+
hosts: localhost
4+
tasks:
5+
- name: Create secret using default value
6+
devolutions.dvls.create_secret:
7+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
8+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
9+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
10+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
11+
secret:
12+
secret_path: "Test-Ansible\\create-secrets"
13+
secret_name: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
14+
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
15+
16+
- name: Create secret specifying value
17+
devolutions.dvls.create_secret:
18+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
19+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
20+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
21+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
22+
secret:
23+
secret_path: "Test-Ansible\\create-secrets"
24+
secret_type: "Credential"
25+
secret_subtype: "Default"
26+
secret_name: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
27+
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
28+
29+
- name: Updating an already existing secret
30+
devolutions.dvls.create_secret:
31+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
32+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
33+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
34+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
35+
secret:
36+
secret_path: "Test-Ansible"
37+
secret_name: "Default"
38+
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
- name: Fetch DVLS
3+
hosts: localhost
4+
vars_files:
5+
- secrets.yml
6+
tasks:
7+
- name: Fetch all secrets
8+
devolutions.dvls.fetch_secrets:
9+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
10+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
11+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
12+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
13+
14+
- name: Fetch secrets using file
15+
devolutions.dvls.fetch_secrets:
16+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
17+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
18+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
19+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
20+
secrets: "{{ secrets }}"
21+
22+
- name: Get secret from ID
23+
devolutions.dvls.fetch_secrets:
24+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
25+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
26+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
27+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
28+
secrets:
29+
- secret_id: 08a6526d-1f86-40e2-aef1-a74cc31a548d
30+
31+
- name: Get secret from name
32+
devolutions.dvls.fetch_secrets:
33+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
34+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
35+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
36+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
37+
secrets:
38+
- secret_name: AzureSP
39+
40+
- name: Get secret from Folder
41+
devolutions.dvls.fetch_secrets:
42+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
43+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
44+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
45+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
46+
secrets:
47+
- secret_path: Test-Ansible
48+
49+
- name: Get secret from Tag
50+
devolutions.dvls.fetch_secrets:
51+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
52+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
53+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
54+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
55+
secrets:
56+
- secret_tag: tag
57+
58+
- name: Get secret from Type
59+
devolutions.dvls.fetch_secrets:
60+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
61+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
62+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
63+
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
64+
secrets:
65+
- secret_type: Credential
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Fetch DVLS
3+
hosts: localhost
4+
tasks:
5+
- name: Fetch dvls server
6+
devolutions.dvls.fetch_server:
7+
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
8+
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
9+
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
10+
register: server

0 commit comments

Comments
 (0)