mirror of https://github.com/ansible/ansible.git
support missing drive letters in PS `path` type (#29884)
* fixes #26623 * Test-Path (and thus `-type path` in Get-AnsibleParam) fail on a nonexistent drive letter, since it can't be mapped to a PSProvider. * added support and basic smoke tests forpull/28972/merge
parent
8515db8588
commit
1e2ce4c8ab
@ -0,0 +1,2 @@
|
|||||||
|
windows/ci/group1
|
||||||
|
windows/ci/smoketest
|
@ -0,0 +1,9 @@
|
|||||||
|
#powershell
|
||||||
|
|
||||||
|
#Requires -Module Ansible.ModuleUtils.Legacy
|
||||||
|
|
||||||
|
$params = Parse-Args $args
|
||||||
|
|
||||||
|
$path = Get-AnsibleParam -Obj $params -Name path -Type path
|
||||||
|
|
||||||
|
Exit-Json @{ path=$path }
|
@ -0,0 +1,23 @@
|
|||||||
|
# NB: these tests are just a placeholder until we have pester unit tests.
|
||||||
|
# They are being run as part of the Windows smoke tests. Please do not significantly
|
||||||
|
# increase the size of these tests, as the smoke tests need to remain fast.
|
||||||
|
# Any significant additions should be made to the (as yet nonexistent) PS module_utils unit tests.
|
||||||
|
|
||||||
|
- name: find a nonexistent drive letter
|
||||||
|
raw: foreach($c in [char[]]([char]'D'..[char]'Z')) { If (-not $(Get-PSDrive $c -ErrorAction SilentlyContinue)) { return $c } }
|
||||||
|
register: bogus_driveletter
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that: bogus_driveletter.stdout_lines[0] | length == 1
|
||||||
|
|
||||||
|
- name: test path shape validation
|
||||||
|
testpath:
|
||||||
|
path: "{{ item.path }}"
|
||||||
|
failed_when: path_shapes | failed != (item.should_fail | default(false))
|
||||||
|
register: path_shapes
|
||||||
|
with_items:
|
||||||
|
- path: C:\Windows
|
||||||
|
- path: HKLM:\Software
|
||||||
|
- path: '{{ bogus_driveletter.stdout_lines[0] }}:\goodpath'
|
||||||
|
- path: '{{ bogus_driveletter.stdout_lines[0] }}:\badpath*%@:\blar'
|
||||||
|
should_fail: true
|
Loading…
Reference in New Issue