Test/MSFT_xExchTransportService.Integration.Tests.ps1

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
###NOTE: This test module requires use of credentials. The first run through of the tests will prompt for credentials from the logged on user.

Import-Module $PSScriptRoot\..\DSCResources\MSFT_xExchTransportService\MSFT_xExchTransportService.psm1
Import-Module $PSScriptRoot\..\Misc\xExchangeCommon.psm1 -Verbose:0
Import-Module $PSScriptRoot\xExchange.Tests.Common.psm1 -Verbose:0

#Check if Exchange is installed on this machine. If not, we can't run tests
[bool]$exchangeInstalled = IsSetupComplete

if ($exchangeInstalled)
{
    #Get required credentials to use for the test
    if ($Global:ShellCredentials -eq $null)
    {
        [PSCredential]$Global:ShellCredentials = Get-Credential -Message "Enter credentials for connecting a Remote PowerShell session to Exchange"
    }

    Describe "Set and modify Transport Service configuration" {
    #Set configuration with default values
    $testParams = @{
         Identity                                = $env:computername
         Credential                              = $Global:ShellCredentials
         AllowServiceRestart                     = $true
         ActiveUserStatisticsLogMaxAge           = '30.00:00:00'
         ActiveUserStatisticsLogMaxDirectorySize = '250MB'
         ActiveUserStatisticsLogMaxFileSize      = '10MB'
         ActiveUserStatisticsLogPath             = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats'
         AgentLogEnabled                         = $true
         AgentLogMaxAge                          = '7.00:00:00'
         AgentLogMaxDirectorySize                = '250MB'
         AgentLogMaxFileSize                     = '10MB'
         AgentLogPath                            = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog'
         ConnectivityLogEnabled                  = $true
         ConnectivityLogMaxAge                   = '30.00:00:00'
         ConnectivityLogMaxDirectorySize         = '1000MB'
         ConnectivityLogMaxFileSize              = '10MB'
         ConnectivityLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity'
         ContentConversionTracingEnabled         = $false
         DelayNotificationTimeout                = '04:00:00'
         DnsLogEnabled                           = $false
         DnsLogMaxAge                            = '7.00:00:00'
         DnsLogMaxDirectorySize                  = '100 MB'
         DnsLogMaxFileSize                       = '10 MB'
         DnsLogPath                              = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\DNS'
         ExternalDNSAdapterEnabled               = $true
         ExternalDNSAdapterGuid                  = '00000000-0000-0000-0000-000000000000'
         ExternalDNSProtocolOption               = 'any'
         ExternalDNSServers                      = ''
         ExternalIPAddress                       = ''
         InternalDNSAdapterEnabled               = $true          
         InternalDNSAdapterGuid                  = '00000000-0000-0000-0000-000000000000'
         InternalDNSProtocolOption               = 'any'
         InternalDNSServers                      = ''
         IntraOrgConnectorProtocolLoggingLevel   = 'none'
         IntraOrgConnectorSmtpMaxMessagesPerConnection = '20'
         IrmLogEnabled                           = $true
         IrmLogMaxAge                            = '30.00:00:00'
         IrmLogMaxDirectorySize                  = '250MB'
         IrmLogMaxFileSize                       = '10MB'
         IrmLogPath                              = 'C:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs'
         MaxConcurrentMailboxDeliveries          = '20'
         MaxConcurrentMailboxSubmissions         = '20'
         MaxConnectionRatePerMinute              = '1200'
         MaxOutboundConnections                  = '1000'
         MaxPerDomainOutboundConnections         = '20'
         MessageExpirationTimeout                = '2.00:00:00'
         MessageRetryInterval                    = '00:15:00'
         MessageTrackingLogEnabled               = $true
         MessageTrackingLogMaxAge                = '30.00:00:00'
         MessageTrackingLogMaxDirectorySize      = '1000MB'
         MessageTrackingLogMaxFileSize           = '10 MB'
         MessageTrackingLogPath                  = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking'
         MessageTrackingLogSubjectLoggingEnabled = $true
         OutboundConnectionFailureRetryInterval  = '00:10:00'
         PickupDirectoryMaxHeaderSize            = '64 KB'
         PickupDirectoryMaxMessagesPerMinute     = '100'
         PickupDirectoryMaxRecipientsPerMessage  = '100'
         PickupDirectoryPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Pickup'
         PipelineTracingEnabled                  = $false
         PipelineTracingPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing'
         PipelineTracingSenderAddress            = ''
         PoisonMessageDetectionEnabled           = $true
         PoisonThreshold                         = '2'
         QueueLogMaxAge                          = '7.00:00:00'
         QueueLogMaxDirectorySize                = '200MB'
         QueueLogMaxFileSize                     = '10MB'
         QueueLogPath                            = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer'
         QueueMaxIdleTime                        = '00:03:00'
         ReceiveProtocolLogMaxAge                = '30.00:00:00'
         ReceiveProtocolLogMaxDirectorySize      = '250MB'
         ReceiveProtocolLogMaxFileSize           = '10 MB'
         ReceiveProtocolLogPath                  = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive'
         RecipientValidationCacheEnabled         = $false
         ReplayDirectoryPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Replay'
         RootDropDirectoryPath                   = ''
         RoutingTableLogMaxAge                   = '7.00:00:00'
         RoutingTableLogMaxDirectorySize         = '50 MB'
         RoutingTableLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing'
         SendProtocolLogMaxAge                   = '30.00:00:00'
         SendProtocolLogMaxDirectorySize         = '250MB'
         SendProtocolLogMaxFileSize              = '10MB'
         SendProtocolLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend'
         ServerStatisticsLogMaxAge               = '30.00:00:00'
         ServerStatisticsLogMaxDirectorySize     = '250MB'
         ServerStatisticsLogMaxFileSize          = '10 MB'
         ServerStatisticsLogPath                 = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats'
         TransientFailureRetryCount              = '6'
         TransientFailureRetryInterval           = '00:05:00'
         UseDowngradedExchangeServerAuth         = $false
    }

    $expectedGetResults = @{
         ActiveUserStatisticsLogMaxAge           = '30.00:00:00'
         ActiveUserStatisticsLogMaxDirectorySize = '250MB'
         ActiveUserStatisticsLogMaxFileSize      = '10MB'
         ActiveUserStatisticsLogPath             = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ActiveUsersStats'
         AgentLogEnabled                         = $true
         AgentLogMaxAge                          = '7.00:00:00'
         AgentLogMaxDirectorySize                = '250MB'
         AgentLogMaxFileSize                     = '10MB'
         AgentLogPath                            = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\AgentLog'
         ConnectivityLogEnabled                  = $true
         ConnectivityLogMaxAge                   = '30.00:00:00'
         ConnectivityLogMaxDirectorySize         = '1000MB'
         ConnectivityLogMaxFileSize              = '10MB'
         ConnectivityLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Connectivity'
         ContentConversionTracingEnabled         = $false
         DelayNotificationTimeout                = '04:00:00'
         DnsLogEnabled                           = $false
         DnsLogMaxAge                            = '7.00:00:00'
         DnsLogMaxDirectorySize                  = '100 MB'
         DnsLogMaxFileSize                       = '10 MB'
         DnsLogPath                              = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\DNS'
         ExternalDNSAdapterEnabled               = $true
         ExternalDNSAdapterGuid                  = '00000000-0000-0000-0000-000000000000'
         ExternalDNSProtocolOption               = 'any'
         ExternalDNSServers                      = $null
         ExternalIPAddress                       = $null
         InternalDNSAdapterEnabled               = $true          
         InternalDNSAdapterGuid                  = '00000000-0000-0000-0000-000000000000'
         InternalDNSProtocolOption               = 'any'
         InternalDNSServers                      = $null
         IntraOrgConnectorProtocolLoggingLevel   = 'none'
         IntraOrgConnectorSmtpMaxMessagesPerConnection = '20'
         IrmLogEnabled                           = $true
         IrmLogMaxAge                            = '30.00:00:00'
         IrmLogMaxDirectorySize                  = '250MB'
         IrmLogMaxFileSize                       = '10MB'
         IrmLogPath                              = 'C:\Program Files\Microsoft\Exchange Server\V15\Logging\IRMLogs'
         MaxConcurrentMailboxDeliveries          = '20'
         MaxConcurrentMailboxSubmissions         = '20'
         MaxConnectionRatePerMinute              = '1200'
         MaxOutboundConnections                  = '1000'
         MaxPerDomainOutboundConnections         = '20'
         MessageExpirationTimeout                = '2.00:00:00'
         MessageRetryInterval                    = '00:15:00'
         MessageTrackingLogEnabled               = $true
         MessageTrackingLogMaxAge                = '30.00:00:00'
         MessageTrackingLogMaxDirectorySize      = '1000MB'
         MessageTrackingLogMaxFileSize           = '10 MB'
         MessageTrackingLogPath                  = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking'
         MessageTrackingLogSubjectLoggingEnabled = $true
         OutboundConnectionFailureRetryInterval  = '00:10:00'
         PickupDirectoryMaxHeaderSize            = '64 KB'
         PickupDirectoryMaxMessagesPerMinute     = '100'
         PickupDirectoryMaxRecipientsPerMessage  = '100'
         PickupDirectoryPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Pickup'
         PipelineTracingEnabled                  = $false
         PipelineTracingPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\PipelineTracing'
         PipelineTracingSenderAddress            = $null
         PoisonMessageDetectionEnabled           = $true
         PoisonThreshold                         = '2'
         QueueLogMaxAge                          = '7.00:00:00'
         QueueLogMaxDirectorySize                = '200MB'
         QueueLogMaxFileSize                     = '10MB'
         QueueLogPath                            = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\QueueViewer'
         QueueMaxIdleTime                        = '00:03:00'
         ReceiveProtocolLogMaxAge                = '30.00:00:00'
         ReceiveProtocolLogMaxDirectorySize      = '250MB'
         ReceiveProtocolLogMaxFileSize           = '10 MB'
         ReceiveProtocolLogPath                  = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive'
         RecipientValidationCacheEnabled         = $false
         ReplayDirectoryPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Replay'
         RootDropDirectoryPath                   = ''
         RoutingTableLogMaxAge                   = '7.00:00:00'
         RoutingTableLogMaxDirectorySize         = '50 MB'
         RoutingTableLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\Routing'
         SendProtocolLogMaxAge                   = '30.00:00:00'
         SendProtocolLogMaxDirectorySize         = '250 MB'
         SendProtocolLogMaxFileSize              = '10MB'
         SendProtocolLogPath                     = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ProtocolLog\SmtpSend'
         ServerStatisticsLogMaxAge               = '30.00:00:00'
         ServerStatisticsLogMaxDirectorySize     = '250MB'
         ServerStatisticsLogMaxFileSize          = '10 MB'
         ServerStatisticsLogPath                 = 'C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\Hub\ServerStats'
         TransientFailureRetryCount              = '6'
         TransientFailureRetryInterval           = '00:05:00'
         UseDowngradedExchangeServerAuth         = $false
    }

     Test-AllTargetResourceFunctions -Params $testParams -ContextLabel "Set default Transport Service configuration" -ExpectedGetResults $expectedGetResults
     
     #modify configuration
     $testParams.InternalDNSServers = '192.168.1.10'
     $testParams.ExternalDNSServers = '10.1.1.10'
     $testParams.PipelineTracingSenderAddress = 'john.doe@contoso.com'
     
     $expectedGetResults.InternalDNSServers = '192.168.1.10'
     $expectedGetResults.ExternalDNSServers = '10.1.1.10'
     $expectedGetResults.PipelineTracingSenderAddress = 'john.doe@contoso.com'

     Test-AllTargetResourceFunctions -Params $testParams -ContextLabel "Modify Transport Service configuration" -ExpectedGetResults $expectedGetResults
     
     #modify configuration
     $testParams.InternalDNSServers = ''
     $testParams.ExternalDNSServers = ''
     $testParams.PipelineTracingSenderAddress = ''
     
     $expectedGetResults.InternalDNSServers = $null
     $expectedGetResults.ExternalDNSServers = $null
     $expectedGetResults.PipelineTracingSenderAddress = $null
     
     Test-AllTargetResourceFunctions -Params $testParams -ContextLabel "Revert Transport Service configuration" -ExpectedGetResults $expectedGetResults
     }
}
else
{
    Write-Verbose "Tests in this file require that Exchange is installed to be run."
}