File size: 2,745 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
try {
    $originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
    if ( ! $IsWindows ) {
        $PSDefaultParameterValues['it:skip'] = $true
    }
    Describe " WSMan SessionOption object" -Tag @("CI") {
        It "The SessionOption type exists" {
            "Microsoft.WSMan.Management.SessionOption" -as "Type" | Should -Not -BeNullOrEmpty
        }
        It "The SessionOption type can be created" {
            $result = [Microsoft.WSMan.Management.SessionOption]::new()
            $result | Should -BeOfType Microsoft.WSMan.Management.SessionOption
        }
        It "The SessionOption type has the proper properties when created with the default constructor" {
            $result = [Microsoft.WSMan.Management.SessionOption]::new()
            $result.SkipCACheck         | Should -BeFalse
            $result.SkipCNCheck         | Should -BeFalse
            $result.SkipRevocationCheck | Should -BeFalse
            $result.UseEncryption       | Should -BeTrue
            $result.UseUtf16            | Should -BeFalse
            $result.ProxyAuthentication | Should -Be 0
            $result.SPNPort             | Should -Be 0
            $result.OperationTimeout    | Should -Be 0
            $result.ProxyCredential     | Should -BeNullOrEmpty
            $result.ProxyAccessType     | Should -Be ProxyIEConfig
        }
        It "The values of SessionOption may be set" {
            $result = [Microsoft.WSMan.Management.SessionOption]::new()
            $result.SkipCACheck = $true
            $result.SkipCNCheck = $true
            $result.SkipRevocationCheck = $true
            $result.UseUtf16 = $true
            $result.UseEncryption = $false
            $result.ProxyAuthentication = "Negotiate"
            $result.SPNPort = 10
            $result.OperationTimeout = 10
            $result.ProxyAccessType = "ProxyAutoDetect"
            $result.ProxyCredential = [System.Net.NetworkCredential]::new("user","pass")

            $result.SkipCACheck         | Should -BeTrue
            $result.SkipCNCheck         | Should -BeTrue
            $result.SkipRevocationCheck | Should -BeTrue
            $result.UseEncryption       | Should -BeFalse
            $result.UseUtf16            | Should -BeTrue
            $result.ProxyAuthentication | Should -Be "Negotiate"
            $result.SPNPort             | Should -Be 10
            $result.OperationTimeout    | Should -Be 10
            $result.ProxyCredential     | Should -Not -BeNullOrEmpty
            $result.ProxyAccessType     | Should -Be "ProxyAutoDetect"
        }
    }
}
finally {
    $global:PSDefaultParameterValues = $originalDefaultParameterValues
}