Skip to content
Snippets Groups Projects
Unverified Commit 9883514c authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman Committed by GitHub
Browse files

Merge pull request #362 from t-woerner/extended_test_users

tests/user/test_users*.yml: Use extended dynamic users.json
parents 8c0b1fb5 b7e1a99b
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## Before starting ## Before starting
In order to run ansible-freeipa tests you will need to have `ansible` and `pytest` installed on your machine. We'll call this local machine `controller`. In order to run ansible-freeipa tests you will need to have `ansible`, `pytest` and `jmespath` installed on your machine. We'll call this local machine `controller`. `jmespath` is needed for the `json_query` filter.
You will also need to have a remote host with freeipa server installed and configured. We'll call this remote host `ipaserver`. You will also need to have a remote host with freeipa server installed and configured. We'll call this remote host `ipaserver`.
......
...@@ -31,6 +31,7 @@ jobs: ...@@ -31,6 +31,7 @@ jobs:
pip install \ pip install \
"molecule[docker]>=3" \ "molecule[docker]>=3" \
"ansible${{ parameters.ansible_version }}" \ "ansible${{ parameters.ansible_version }}" \
jmespath \
pytest \ pytest \
pytest-split-tests pytest-split-tests
displayName: Install dependencies displayName: Install dependencies
......
---
- name: Create users.json
hosts: localhost
tasks:
- name: Check if users.json exists
stat:
path: users.json
register: register_stat_users
- name: Create users.json
command: /bin/bash users.sh 500
when: not register_stat_users.stat.exists
--- ---
- name: Include create_users_json.yml
import_playbook: create_users_json.yml
- name: Test users absent - name: Test users absent
hosts: ipaserver hosts: ipaserver
become: true become: true
gather_facts: false gather_facts: false
tasks: tasks:
- name: Include users_absent.json - name: Include users.json
include_vars: include_vars:
file: users_absent.json file: users.json
- name: Users absent - name: Users absent len:{{ users | length }}
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
users: "{{ users }}" users: "{{ users | json_query('[*].{name: name}') }}"
state: absent state: absent
--- ---
- name: Include create_users_json.yml
import_playbook: create_users_json.yml
- name: Test users present - name: Test users present
hosts: ipaserver hosts: ipaserver
become: true become: true
gather_facts: false gather_facts: false
tasks: tasks:
- name: Include users_present.json - name: Include users.json
include_vars: include_vars:
file: users_present.json file: users.json
- name: Users present - name: Users present len:{{ users | length }}
ipauser: ipauser:
ipaadmin_password: SomeADMINpassword ipaadmin_password: SomeADMINpassword
users: "{{ users }}" users: "{{ users }}"
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
vars: vars:
slice_size: 500 slice_size: 500
tasks: tasks:
- name: Include users_present.json - name: Include users.json
include_vars: include_vars:
file: users_present.json file: users.json
- debug: - debug:
msg: "{{ users | length }}" msg: "{{ users | length }}"
- name: Users present - name: Users present
......
#!/bin/bash #!/bin/bash
NUM=1000 NUM=${1-1000}
FILE="users_present.json" FILE="users.json"
date=$(date --date='+2 years' "+%Y-%m-%d %H:%M:%S")
echo "{" > $FILE echo "{" > $FILE
...@@ -11,7 +12,9 @@ for i in $(seq 1 $NUM); do ...@@ -11,7 +12,9 @@ for i in $(seq 1 $NUM); do
echo " {" >> $FILE echo " {" >> $FILE
echo " \"name\": \"user$i\"," >> $FILE echo " \"name\": \"user$i\"," >> $FILE
echo " \"first\": \"First $i\"," >> $FILE echo " \"first\": \"First $i\"," >> $FILE
echo " \"last\": \"Last $i\"" >> $FILE echo " \"last\": \"Last $i\"," >> $FILE
echo " \"password\": \"user${i}PW\"," >> $FILE
echo " \"passwordexpiration\": \"$date\"" >> $FILE
if [ $i -lt $NUM ]; then if [ $i -lt $NUM ]; then
echo " }," >> $FILE echo " }," >> $FILE
else else
......
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment