Skip to content

Commit b59bc57

Browse files
committed
test: add integration test for get and create
1 parent a3c3e67 commit b59bc57

File tree

5 files changed

+184
-0
lines changed

5 files changed

+184
-0
lines changed

.github/workflows/test.yml

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