|
1 | 1 | --- |
2 | | -- name: Test routerdynamicrouting_info module |
| 2 | +# Test 1: Valid command with "show" |
| 3 | +- name: Test valid show command |
3 | 4 | delegate_to: localhost |
4 | 5 | register: result |
5 | 6 | check_mode: true |
6 | 7 | tags: test |
7 | | - tasks: |
8 | | - # Test 1: Valid command with "show" |
9 | | - - name: Test valid show command |
10 | | - delegate_to: localhost |
11 | | - netscaler.adc.routerdynamicrouting_info: |
12 | | - nsip: "{{ nsip }}" |
13 | | - nitro_user: "{{ nitro_user }}" |
14 | | - nitro_pass: "{{ nitro_pass }}" |
15 | | - nitro_protocol: "{{ nitro_protocol }}" |
16 | | - validate_certs: "{{ validate_certs }}" |
17 | | - commandstring: "show ip route" |
18 | | - register: result |
| 8 | + netscaler.adc.routerdynamicrouting_info: |
| 9 | + nsip: "{{ nsip }}" |
| 10 | + nitro_user: "{{ nitro_user }}" |
| 11 | + nitro_pass: "{{ nitro_pass }}" |
| 12 | + nitro_protocol: "{{ nitro_protocol }}" |
| 13 | + validate_certs: "{{ validate_certs }}" |
| 14 | + commandstring: "show ip route" |
19 | 15 |
|
20 | | - - name: Assert show command succeeded |
21 | | - assert: |
22 | | - that: |
23 | | - - not result.changed |
24 | | - - not result.failed |
25 | | - - result.info is defined |
26 | | - - result.info.commandstring == "show ip route" |
| 16 | +- name: Assert show command succeeded |
| 17 | + tags: test |
| 18 | + assert: |
| 19 | + that: |
| 20 | + - not result.changed |
| 21 | + - not result.failed |
| 22 | + - result.info is defined |
| 23 | + - result.info.commandstring == "show ip route" |
27 | 24 |
|
28 | | - # Test 2: Valid command with "sh" |
29 | | - - name: Test valid sh command |
30 | | - delegate_to: localhost |
31 | | - netscaler.adc.routerdynamicrouting_info: |
32 | | - nsip: "{{ nsip }}" |
33 | | - nitro_user: "{{ nitro_user }}" |
34 | | - nitro_pass: "{{ nitro_pass }}" |
35 | | - nitro_protocol: "{{ nitro_protocol }}" |
36 | | - validate_certs: "{{ validate_certs }}" |
37 | | - commandstring: "sh ip bgp summary" |
38 | | - register: result |
| 25 | +# Test 2: Valid command with "sh" |
| 26 | +- name: Test valid sh command |
| 27 | + delegate_to: localhost |
| 28 | + register: result |
| 29 | + check_mode: true |
| 30 | + tags: test |
| 31 | + netscaler.adc.routerdynamicrouting_info: |
| 32 | + nsip: "{{ nsip }}" |
| 33 | + nitro_user: "{{ nitro_user }}" |
| 34 | + nitro_pass: "{{ nitro_pass }}" |
| 35 | + nitro_protocol: "{{ nitro_protocol }}" |
| 36 | + validate_certs: "{{ validate_certs }}" |
| 37 | + commandstring: "sh ip bgp summary" |
39 | 38 |
|
40 | | - - name: Assert sh command succeeded |
41 | | - assert: |
42 | | - that: |
43 | | - - not result.changed |
44 | | - - not result.failed |
45 | | - - result.info is defined |
46 | | - - result.info.commandstring == "sh ip bgp summary" |
| 39 | +- name: Assert sh command succeeded |
| 40 | + tags: test |
| 41 | + assert: |
| 42 | + that: |
| 43 | + - not result.changed |
| 44 | + - not result.failed |
| 45 | + - result.info is defined |
| 46 | + - result.info.commandstring == "sh ip bgp summary" |
47 | 47 |
|
48 | | - # Test 3: Command with uppercase SHOW |
49 | | - - name: Test uppercase SHOW command |
50 | | - delegate_to: localhost |
51 | | - netscaler.adc.routerdynamicrouting_info: |
52 | | - nsip: "{{ nsip }}" |
53 | | - nitro_user: "{{ nitro_user }}" |
54 | | - nitro_pass: "{{ nitro_pass }}" |
55 | | - nitro_protocol: "{{ nitro_protocol }}" |
56 | | - validate_certs: "{{ validate_certs }}" |
57 | | - commandstring: "SHOW ip ospf neighbor" |
58 | | - register: result |
| 48 | +# Test 3: Command with uppercase SHOW |
| 49 | +- name: Test uppercase SHOW command |
| 50 | + delegate_to: localhost |
| 51 | + register: result |
| 52 | + check_mode: true |
| 53 | + tags: test |
| 54 | + netscaler.adc.routerdynamicrouting_info: |
| 55 | + nsip: "{{ nsip }}" |
| 56 | + nitro_user: "{{ nitro_user }}" |
| 57 | + nitro_pass: "{{ nitro_pass }}" |
| 58 | + nitro_protocol: "{{ nitro_protocol }}" |
| 59 | + validate_certs: "{{ validate_certs }}" |
| 60 | + commandstring: "SHOW ip ospf neighbor" |
59 | 61 |
|
60 | | - - name: Assert uppercase SHOW command succeeded |
61 | | - assert: |
62 | | - that: |
63 | | - - not result.changed |
64 | | - - not result.failed |
65 | | - - result.info is defined |
| 62 | +- name: Assert uppercase SHOW command succeeded |
| 63 | + tags: test |
| 64 | + assert: |
| 65 | + that: |
| 66 | + - not result.changed |
| 67 | + - not result.failed |
| 68 | + - result.info is defined |
66 | 69 |
|
67 | | - # Test 4: Invalid command (should fail) |
68 | | - - name: Test invalid command (not starting with sh/show) |
69 | | - delegate_to: localhost |
70 | | - netscaler.adc.routerdynamicrouting_info: |
71 | | - nsip: "{{ nsip }}" |
72 | | - nitro_user: "{{ nitro_user }}" |
73 | | - nitro_pass: "{{ nitro_pass }}" |
74 | | - nitro_protocol: "{{ nitro_protocol }}" |
75 | | - validate_certs: "{{ validate_certs }}" |
76 | | - commandstring: "configure terminal" |
77 | | - register: result |
78 | | - ignore_errors: true |
| 70 | +# Test 4: Invalid command (should fail) |
| 71 | +- name: Test invalid command (not starting with sh/show) |
| 72 | + delegate_to: localhost |
| 73 | + register: result |
| 74 | + check_mode: true |
| 75 | + tags: test |
| 76 | + netscaler.adc.routerdynamicrouting_info: |
| 77 | + nsip: "{{ nsip }}" |
| 78 | + nitro_user: "{{ nitro_user }}" |
| 79 | + nitro_pass: "{{ nitro_pass }}" |
| 80 | + nitro_protocol: "{{ nitro_protocol }}" |
| 81 | + validate_certs: "{{ validate_certs }}" |
| 82 | + commandstring: "configure terminal" |
| 83 | + ignore_errors: true |
79 | 84 |
|
80 | | - - name: Assert invalid command failed |
81 | | - assert: |
82 | | - that: |
83 | | - - result.failed |
84 | | - - "'must start with' in result.msg" |
| 85 | +- name: Assert invalid command failed |
| 86 | + tags: test |
| 87 | + assert: |
| 88 | + that: |
| 89 | + - result.failed |
| 90 | + - "'must start with' in result.msg" |
85 | 91 |
|
86 | | - # Test 5: Another invalid command |
87 | | - - name: Test another invalid command |
88 | | - delegate_to: localhost |
89 | | - netscaler.adc.routerdynamicrouting_info: |
90 | | - nsip: "{{ nsip }}" |
91 | | - nitro_user: "{{ nitro_user }}" |
92 | | - nitro_pass: "{{ nitro_pass }}" |
93 | | - nitro_protocol: "{{ nitro_protocol }}" |
94 | | - validate_certs: "{{ validate_certs }}" |
95 | | - commandstring: "delete ip route" |
96 | | - register: result |
97 | | - ignore_errors: true |
| 92 | +# Test 5: Another invalid command |
| 93 | +- name: Test another invalid command |
| 94 | + delegate_to: localhost |
| 95 | + register: result |
| 96 | + check_mode: true |
| 97 | + tags: test |
| 98 | + netscaler.adc.routerdynamicrouting_info: |
| 99 | + nsip: "{{ nsip }}" |
| 100 | + nitro_user: "{{ nitro_user }}" |
| 101 | + nitro_pass: "{{ nitro_pass }}" |
| 102 | + nitro_protocol: "{{ nitro_protocol }}" |
| 103 | + validate_certs: "{{ validate_certs }}" |
| 104 | + commandstring: "delete ip route" |
| 105 | + ignore_errors: true |
98 | 106 |
|
99 | | - - name: Assert delete command failed |
100 | | - assert: |
101 | | - that: |
102 | | - - result.failed |
103 | | - - "'must start with' in result.msg" |
| 107 | +- name: Assert delete command failed |
| 108 | + tags: test |
| 109 | + assert: |
| 110 | + that: |
| 111 | + - result.failed |
| 112 | + - "'must start with' in result.msg" |
104 | 113 |
|
105 | | - # Test 6: Command with leading whitespace |
106 | | - - name: Test command with leading whitespace |
107 | | - delegate_to: localhost |
108 | | - netscaler.adc.routerdynamicrouting_info: |
109 | | - nsip: "{{ nsip }}" |
110 | | - nitro_user: "{{ nitro_user }}" |
111 | | - nitro_pass: "{{ nitro_pass }}" |
112 | | - nitro_protocol: "{{ nitro_protocol }}" |
113 | | - validate_certs: "{{ validate_certs }}" |
114 | | - commandstring: " show ip route" |
115 | | - register: result |
| 114 | +# Test 6: Command with leading whitespace |
| 115 | +- name: Test command with leading whitespace |
| 116 | + delegate_to: localhost |
| 117 | + register: result |
| 118 | + check_mode: true |
| 119 | + tags: test |
| 120 | + netscaler.adc.routerdynamicrouting_info: |
| 121 | + nsip: "{{ nsip }}" |
| 122 | + nitro_user: "{{ nitro_user }}" |
| 123 | + nitro_pass: "{{ nitro_pass }}" |
| 124 | + nitro_protocol: "{{ nitro_protocol }}" |
| 125 | + validate_certs: "{{ validate_certs }}" |
| 126 | + commandstring: " show ip route" |
116 | 127 |
|
117 | | - - name: Assert command with whitespace succeeded |
118 | | - assert: |
119 | | - that: |
120 | | - - not result.changed |
121 | | - - not result.failed |
122 | | - - result.info is defined |
| 128 | +- name: Assert command with whitespace succeeded |
| 129 | + tags: test |
| 130 | + assert: |
| 131 | + that: |
| 132 | + - not result.changed |
| 133 | + - not result.failed |
| 134 | + - result.info is defined |
0 commit comments