Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Test module

on:
workflow_dispatch:
pull_request:
branches: master

jobs:
integration-test:
environment: test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x

- name: Install Python dependencies
run: |
pip install ansible
pip install requests
python -m pip install --upgrade pip
pip list

- name: Build
id: build
run: |
OUTPUT=$(ansible-galaxy collection build)
echo "$OUTPUT"
COLLECTION_PATH=$(echo "$OUTPUT" | grep -o '/[^ ]*\.tar\.gz')
echo "collection_path=$COLLECTION_PATH" >> $GITHUB_OUTPUT
echo "Collection path: $COLLECTION_PATH"

- name: Install collection
run: ansible-galaxy collection install ${{ steps.build.outputs.collection_path }} --force
working-directory: tests/integration

- name: Run get-vaults
run: ansible-playbook test_get_vault.yml
working-directory: tests/integration
env:
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}

- name: Run get-secrets
run: ansible-playbook test_get_secret.yml
working-directory: tests/integration
env:
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}

- name: Run create-secrets
run: ansible-playbook test_create_secret.yml
working-directory: tests/integration
env:
DVLS_APP_KEY: ${{ secrets.DVLS_APP_KEY }}
DVLS_APP_SECRET: ${{ secrets.DVLS_APP_SECRET }}
DVLS_SERVER_BASE_URL: ${{ secrets.DVLS_SERVER_BASE_URL }}
DVLS_VAULT_ID: ${{ secrets.DVLS_VAULT_ID }}
3 changes: 3 additions & 0 deletions tests/integration/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
secrets:
- secret_name: "secret"
- secret_id: "890cbb54-7078-4d0c-925f-e89a33ee3e46"
38 changes: 38 additions & 0 deletions tests/integration/test_create_secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: Fetch DVLS
hosts: localhost
tasks:
- name: Create secret using default value
devolutions.dvls.create_secret:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secret:
secret_path: "Test-Ansible\\create-secrets"
secret_name: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"

- name: Create secret specifying value
devolutions.dvls.create_secret:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secret:
secret_path: "Test-Ansible\\create-secrets"
secret_type: "Credential"
secret_subtype: "Default"
secret_name: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"

- name: Updating an already existing secret
devolutions.dvls.create_secret:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secret:
secret_path: "Test-Ansible"
secret_name: "Default"
value: "{{ now(fmt='%Y-%m-%d_%H-%M-%S') }}"
65 changes: 65 additions & 0 deletions tests/integration/test_get_secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
- name: Fetch DVLS
hosts: localhost
vars_files:
- secrets.yml
tasks:
- name: Fetch all secrets
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"

- name: Fetch secrets using file
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets: "{{ secrets }}"

- name: Get secret from ID
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets:
- secret_id: 08a6526d-1f86-40e2-aef1-a74cc31a548d

- name: Get secret from name
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets:
- secret_name: AzureSP

- name: Get secret from Folder
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets:
- secret_path: Test-Ansible

- name: Get secret from Tag
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets:
- secret_tag: tag

- name: Get secret from Type
devolutions.dvls.fetch_secrets:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
vault_id: "{{ lookup('env', 'DVLS_VAULT_ID') }}"
secrets:
- secret_type: Credential
10 changes: 10 additions & 0 deletions tests/integration/test_get_vault.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Fetch DVLS
hosts: localhost
tasks:
- name: Fetch dvls server
devolutions.dvls.fetch_server:
server_base_url: "{{ lookup('env', 'DVLS_SERVER_BASE_URL') }}"
app_key: "{{ lookup('env', 'DVLS_APP_KEY') }}"
app_secret: "{{ lookup('env', 'DVLS_APP_SECRET') }}"
register: server