diff options
author | CaptTrews <capttrews@gmail.com> | 2020-01-16 15:50:24 +0000 |
---|---|---|
committer | CaptTrews <capttrews@gmail.com> | 2020-01-16 15:50:24 +0000 |
commit | 6b6166151faa3d811ae0ec3010a89e518a26287b (patch) | |
tree | 9cf59872c2ddc7e99595db4f47c72a7ce08b6c10 /tests/integration/targets/vyos_user | |
parent | d31b74ba6c74a6e3cdebd80b9eb5272aeb9b0fb4 (diff) | |
download | vyos-ansible-old-6b6166151faa3d811ae0ec3010a89e518a26287b.tar.gz vyos-ansible-old-6b6166151faa3d811ae0ec3010a89e518a26287b.zip |
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
Diffstat (limited to 'tests/integration/targets/vyos_user')
5 files changed, 62 insertions, 46 deletions
diff --git a/tests/integration/targets/vyos_user/defaults/main.yaml b/tests/integration/targets/vyos_user/defaults/main.yaml index 9ef5ba5..a845c24 100644 --- a/tests/integration/targets/vyos_user/defaults/main.yaml +++ b/tests/integration/targets/vyos_user/defaults/main.yaml @@ -1,3 +1,3 @@ --- -testcase: "*" +testcase: '*' test_items: [] diff --git a/tests/integration/targets/vyos_user/tasks/cli.yaml b/tests/integration/targets/vyos_user/tasks/cli.yaml index 890d3ac..90f265f 100644 --- a/tests/integration/targets/vyos_user/tasks/cli.yaml +++ b/tests/integration/targets/vyos_user/tasks/cli.yaml @@ -1,22 +1,22 @@ --- - name: collect all cli test cases find: - paths: "{{ role_path }}/tests/cli" - patterns: "{{ testcase }}.yaml" + paths: '{{ role_path }}/tests/cli' + patterns: '{{ testcase }}.yaml' register: test_cases delegate_to: localhost - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case (connection=network_cli) - include: "{{ test_case_to_run }} ansible_connection=network_cli" - with_items: "{{ test_items }}" +- name: run test case (connection=ansible.netcommon.network_cli) + include: '{{ test_case_to_run }} ansible_connection=ansible.netcommon.network_cli' + with_items: '{{ test_items }}' loop_control: loop_var: test_case_to_run - name: run test case (connection=local) - include: "{{ test_case_to_run }} ansible_connection=local" - with_first_found: "{{ test_items }}" + include: '{{ test_case_to_run }} ansible_connection=local' + with_first_found: '{{ test_items }}' loop_control: loop_var: test_case_to_run diff --git a/tests/integration/targets/vyos_user/tasks/main.yaml b/tests/integration/targets/vyos_user/tasks/main.yaml index d4cf26f..a3db933 100644 --- a/tests/integration/targets/vyos_user/tasks/main.yaml +++ b/tests/integration/targets/vyos_user/tasks/main.yaml @@ -1,2 +1,4 @@ --- -- {include: cli.yaml, tags: ['cli']} +- include: cli.yaml + tags: + - cli diff --git a/tests/integration/targets/vyos_user/tests/cli/auth.yaml b/tests/integration/targets/vyos_user/tests/cli/auth.yaml index bbd67bc..bc4e788 100644 --- a/tests/integration/targets/vyos_user/tests/cli/auth.yaml +++ b/tests/integration/targets/vyos_user/tests/cli/auth.yaml @@ -1,34 +1,39 @@ --- - block: - - name: Create user with password - vyos.vyos.vyos_user: - name: auth_user - role: admin - state: present - configured_password: pass123 - - name: test login via ssh with new user - expect: - command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'" - responses: - (?i)password: "pass123" + - name: Create user with password + vyos.vyos.vyos_user: + name: auth_user + role: admin + state: present + configured_password: pass123 - - name: test login via ssh with invalid password (should fail) - expect: - command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper show version'" - responses: - (?i)password: "badpass" - ignore_errors: true - register: results + - name: test login via ssh with new user + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) + }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + show version' + responses: + (?i)password: pass123 - - name: check that attempt failed - assert: - that: - - results.failed + - name: test login via ssh with invalid password (should fail) + expect: + command: ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_port | default(22) + }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no '/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper + show version' + responses: + (?i)password: badpass + ignore_errors: true + register: results + - name: check that attempt failed + assert: + that: + - results.failed always: + - name: delete user + register: result vyos.vyos.vyos_user: name: auth_user state: absent - register: result diff --git a/tests/integration/targets/vyos_user/tests/cli/basic.yaml b/tests/integration/targets/vyos_user/tests/cli/basic.yaml index a71f9c6..00a7a26 100644 --- a/tests/integration/targets/vyos_user/tests/cli/basic.yaml +++ b/tests/integration/targets/vyos_user/tests/cli/basic.yaml @@ -9,69 +9,78 @@ - delete system login user ansibletest3 - name: Create user + register: result vyos.vyos.vyos_user: name: ansibletest1 configured_password: test state: present - register: result - assert: that: - - 'result.changed == true' + - result.changed == true - '"set system login user" in result.commands[0]' - '"authentication plaintext-password" in result.commands[0]' - name: Collection of users (SetUp) + register: result vyos.vyos.vyos_user: aggregate: + - name: ansibletest2 + - name: ansibletest3 level: operator state: present - register: result - assert: that: - - 'result.changed == true' - - 'result.commands == ["set system login user ansibletest2 level operator", "set system login user ansibletest3 level operator"]' + - result.changed == true + - result.commands == ["set system login user ansibletest2 level operator", + "set system login user ansibletest3 level operator"] - name: Add user again (Idempotent) + register: result vyos.vyos.vyos_user: name: ansibletest1 configured_password: test state: present update_password: on_create - register: result - assert: that: - - 'result.changed == false' - - 'result.commands | length == 0' + - result.changed == false + - result.commands | length == 0 - name: Add collection of users (Idempotent) + register: result vyos.vyos.vyos_user: aggregate: + - name: ansibletest2 + - name: ansibletest3 level: operator state: present - register: result - assert: that: - - 'result.changed == false' - - 'result.commands | length == 0' + - result.changed == false + - result.commands | length == 0 - name: tearDown + register: result vyos.vyos.vyos_user: users: + - name: ansibletest1 + - name: ansibletest2 + - name: ansibletest3 state: absent - register: result - assert: that: - - 'result.changed == true' - - 'result.commands == ["delete system login user ansibletest1", "delete system login user ansibletest2", "delete system login user ansibletest3"]' + - result.changed == true + - result.commands == ["delete system login user ansibletest1", "delete system + login user ansibletest2", "delete system login user ansibletest3"] |