summaryrefslogtreecommitdiff
path: root/test/integration/targets/win_inet_proxy/tasks/tests.yml
blob: 47ddfbe2e802a17ba6410742d58215ef256f7540 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
---
- name: ensure we fail when proxy is not set with bypass
  win_inet_proxy:
    bypass: abc
  register: fail_bypass
  failed_when: 'fail_bypass.msg != "missing parameter(s) required by ''bypass'': proxy"'

- name: ensure we fail if an invalid protocol is specified
  win_inet_proxy:
    proxy:
      fail1: fail
      fail2: fail
  register: fail_proxy
  failed_when: 'fail_proxy.msg != "Invalid keys found in proxy: fail1, fail2. Valid keys are http, https, ftp, socks."'

- name: ensure we fail if invalid value is set
  win_inet_proxy:
    proxy: fake=proxy
  register: fail_invalid
  failed_when: fail_invalid.msg != "Unknown error when trying to set auto_config_url '', proxy 'fake=proxy', or bypass ''"

- name: ensure we fail if an invalid connection is set
  win_inet_proxy:
    connection: Fake Connection
  register: fail_connection
  failed_when: fail_connection.msg != "The connection 'Fake Connection' does not exist."

- name: check proxy is still set to Direct access
  win_inet_proxy_info:
  register: fail_invalid_actual
  failed_when: fail_invalid_actual.proxy == 'fake=proxy'

- name: disable auto detect (check)
  win_inet_proxy:
    auto_detect: no
  register: disable_auto_detect_check
  check_mode: yes

- name: get result of disable auto detect (check)
  win_inet_proxy_info:
  register: disable_auto_detect_actual_check

- name: assert disable auto detect (check)
  assert:
    that:
    - disable_auto_detect_check is changed
    - disable_auto_detect_actual_check.auto_detect

- name: disable auto detect
  win_inet_proxy:
    auto_detect: no
  register: disable_auto_detect

- name: get result of disable auto detect
  win_inet_proxy_info:
  register: disable_auto_detect_actual

- name: assert disable auto detect
  assert:
    that:
    - disable_auto_detect is changed
    - not disable_auto_detect_actual.auto_detect

- name: disable auto detect (idempotent)
  win_inet_proxy:
    auto_detect: no
  register: disable_auto_detect_again

- name: assert disable auto detect (idempotent)
  assert:
    that:
    - not disable_auto_detect_again is changed

- name: set auto config url
  win_inet_proxy:
    auto_config_url: http://ansible.com/proxy.pac
  register: set_auto_url

- name: get result of set auto config url
  win_inet_proxy_info:
  register: set_auto_url_actual

- name: assert set auto config url
  assert:
    that:
    - set_auto_url is changed
    - set_auto_url_actual.auto_detect
    - set_auto_url_actual.auto_config_url == 'http://ansible.com/proxy.pac'

- name: set auto config url (idempotent)
  win_inet_proxy:
    auto_config_url: http://ansible.com/proxy.pac
  register: set_auto_url_again

- name: set auto config url (idempotent)
  assert:
    that:
    - not set_auto_url_again is changed

- name: set a proxy using a string
  win_inet_proxy:
    proxy: proxyhost
  register: proxy_str

- name: get result of set a proxy using a string
  win_inet_proxy_info:
  register: proxy_str_actual

- name: assert set a proxy using a string
  assert:
    that:
    - proxy_str is changed
    - proxy_str_actual.auto_detect
    - proxy_str_actual.auto_config_url == None
    - proxy_str_actual.proxy == 'proxyhost'

- name: set a proxy using a string (idempotent)
  win_inet_proxy:
    proxy: proxyhost
  register: proxy_str_again

- name: assert set a proxy using a string (idempotent)
  assert:
    that:
    - not proxy_str_again is changed

- name: change a proxy and set bypass
  win_inet_proxy:
    proxy: proxyhost:8080
    bypass:
    - abc
    - def
    - <local>
  register: change_proxy

- name: get result of change a proxy and set bypass
  win_inet_proxy_info:
  register: change_proxy_actual

- name: assert change a proxy and set bypass
  assert:
    that:
    - change_proxy is changed
    - change_proxy_actual.proxy == 'proxyhost:8080'
    - change_proxy_actual.bypass == 'abc;def;<local>'

- name: change a proxy and set bypass (idempotent)
  win_inet_proxy:
    proxy: proxyhost:8080
    bypass: abc,def,<local>
  register: change_proxy_again

- name: assert change a proxy and set bypass (idempotent)
  assert:
    that:
    - not change_proxy_again is changed

- name: change bypass list
  win_inet_proxy:
    proxy: proxyhost:8080
    bypass:
    - abc
    - <-loopback>
  register: change_bypass

- name: get reuslt of change bypass list
  win_inet_proxy_info:
  register: change_bypass_actual

- name: assert change bypass list
  assert:
    that:
    - change_bypass is changed
    - change_bypass_actual.proxy == 'proxyhost:8080'
    - change_bypass_actual.bypass == 'abc;<-loopback>'

- name: remove proxy without options
  win_inet_proxy:
  register: remove_proxy

- name: get result of remove proxy without options
  win_inet_proxy_info:
  register: remove_proxy_actual

- name: assert remove proxy without options
  assert:
    that:
    - remove_proxy is changed
    - remove_proxy_actual.auto_detect == True
    - remove_proxy_actual.auto_config_url == None
    - remove_proxy_actual.proxy == None
    - remove_proxy_actual.bypass == None

- name: remove proxy without options (idempotent)
  win_inet_proxy:
  register: remove_proxy_again

- name: assert remove proxy without options (idempotent)
  assert:
    that:
    - not remove_proxy_again is changed

- name: set proxy with dictionary
  win_inet_proxy:
    proxy:
      http: proxy:8080
      https: proxy:8443
      ftp: proxy:821
      socks: proxy:888
  register: set_dict

- name: get result of set proxy with dictionary
  win_inet_proxy_info:
  register: set_dict_actual

- name: assert set proxy with dictionary
  assert:
    that:
    - set_dict is changed
    - set_dict_actual.proxy == 'http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888'

- name: set proxy protocol with str
  win_inet_proxy:
    proxy: http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888
  register: set_str_protocol

- name: assert set proxy protocol with str
  assert:
    that:
    - not set_str_protocol is changed

- name: remove proxy with empty string
  win_inet_proxy:
    proxy: ''
  register: remove_empty_str

- name: get result of remove proxy with empty string
  win_inet_proxy_info:
  register: remove_empty_str_actual

- name: assert remove proxy with empty string
  assert:
    that:
    - remove_empty_str is changed
    - remove_empty_str_actual.proxy == None

- name: create test phonebook entry
  win_phonebook_entry:
    name: Ansible Test Dialup
    device_type: pppoe
    device_name: WAN Miniport (PPPOE)
    framing_protocol: ppp
    options:
    - remote_default_gateway
    - require_pap
    - internet
    type: broadband
    state: present

- name: set proxy for specific connection
  win_inet_proxy:
    connection: Ansible Test Dialup
    auto_detect: no
    auto_config_url: proxy.com
    proxy: proxyhost:8080
    bypass: proxyhost
  register: set_connection

- name: get result for set proxy for specific connection
  win_inet_proxy_info:
    connection: Ansible Test Dialup
  register: set_connection_actual

- name: get result for LAN connection proxy
  win_inet_proxy_info:
  register: set_connection_lan_actual

- name: assert set proxy for specific connection
  assert:
    that:
    - set_connection is changed
    - set_connection_actual.auto_detect == False
    - set_connection_actual.auto_config_url == 'proxy.com'
    - set_connection_actual.proxy == 'proxyhost:8080'
    - set_connection_actual.bypass == 'proxyhost'
    - set_connection_lan_actual.auto_detect == True
    - set_connection_lan_actual.auto_config_url == None
    - set_connection_lan_actual.proxy == None
    - set_connection_lan_actual.bypass == None

- name: remove proxy for specific connection
  win_inet_proxy:
    connection: Ansible Test Dialup
  register: remove_connection

- name: get result of remove proxy for specific connection
  win_inet_proxy_info:
    connection: Ansible Test Dialup
  register: remove_connection_actual

- name: assert remove proxy for specific connection
  assert:
    that:
    - remove_connection is changed
    - remove_connection_actual.auto_detect == True
    - remove_connection_actual.auto_config_url == None
    - remove_connection_actual.proxy == None
    - remove_connection_actual.bypass == None