Moved ProviderCollectionTest.cs from System assembly to System.Configuration.
[mono.git] / mcs / class / System.ServiceModel / Test / System.ServiceModel.Configuration / ServiceBehaviorElementTest.cs
1 //
2 // ServiceBehaviorElementTest.cs
3 //
4 // Author:
5 //      Igor Zelmanovich <igorz@mainsoft.com>
6 //
7 // Copyright (C) 2008 Mainsoft, Inc.  http://www.mainsoft.com
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System;
30 using System.Collections.Generic;
31 using System.Text;
32 using NUnit.Framework;
33 using System.ServiceModel.Configuration;
34 using System.ServiceModel.Description;
35 using System.Configuration;
36 using System.ServiceModel;
37 using System.Security.Cryptography.X509Certificates;
38 using System.ServiceModel.Security;
39
40 namespace MonoTests.System.ServiceModel.Configuration
41 {
42         [TestFixture]
43         public class ServiceBehaviorElementTest
44         {
45                 ServiceBehaviorElement OpenConfig () {
46                         ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/serviceBehaviors").GetSectionGroup ("system.serviceModel");
47                         return config.Behaviors.ServiceBehaviors [0];
48                 }
49
50                 [Test]
51                 public void ServiceAuthorizationElement () {
52                         ServiceBehaviorElement behavior = OpenConfig ();
53                         ServiceAuthorizationElement serviceAuthorization = (ServiceAuthorizationElement) behavior [typeof (ServiceAuthorizationElement)];
54
55                         if (serviceAuthorization == null)
56                                 Assert.Fail ("ServiceAuthorizationElement is not exist in collection.");
57
58                         Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
59                         Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
60
61                         Assert.AreEqual ("RoleProvider", serviceAuthorization.RoleProviderName, "RoleProviderName");
62                         Assert.AreEqual (PrincipalPermissionMode.UseAspNetRoles, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
63                         Assert.AreEqual (true, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
64                         Assert.AreEqual ("SerAuthManagType", serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
65
66                         Assert.AreEqual (2, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
67                         Assert.AreEqual ("PolicyType1", serviceAuthorization.AuthorizationPolicies [0].PolicyType, "AuthorizationPolicies[0].PolicyType");
68                         Assert.AreEqual ("PolicyType2", serviceAuthorization.AuthorizationPolicies [1].PolicyType, "AuthorizationPolicies[1].PolicyType");
69                 }
70
71                 [Test]
72                 public void ServiceAuthorizationElement_default () {
73                         ServiceAuthorizationElement serviceAuthorization = new ServiceAuthorizationElement ();
74
75                         Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
76                         Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
77
78                         Assert.AreEqual (String.Empty, serviceAuthorization.RoleProviderName, "RoleProviderName");
79                         Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
80                         Assert.AreEqual (false, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
81                         Assert.AreEqual (String.Empty, serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
82
83                         Assert.AreEqual (0, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
84                 }
85
86                 [Test]
87                 public void DataContractSerializerElement () {
88                         ServiceBehaviorElement behavior = OpenConfig ();
89                         DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
90
91                         if (element == null)
92                                 Assert.Fail ("DataContractSerializerElement is not exist in collection.");
93
94                         Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
95                         Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
96
97                         Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
98                         Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
99                 }
100
101                 [Test]
102                 public void DataContractSerializerElement_defaults () {
103                         DataContractSerializerElement element = new DataContractSerializerElement ();
104
105                         Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
106                         Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
107
108                         Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
109                         Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
110                 }
111
112                 [Test]
113                 public void ServiceDebugElement () {
114                         ServiceBehaviorElement behavior = OpenConfig ();
115                         ServiceDebugElement element = (ServiceDebugElement) behavior [typeof (ServiceDebugElement)];
116
117                         if (element == null)
118                                 Assert.Fail ("ServiceDebugElement is not exist in collection.");
119
120                         Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
121                         Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
122
123                         Assert.AreEqual (false, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
124                         Assert.AreEqual ("http://help.page.url", element.HttpHelpPageUrl.OriginalString, "HttpHelpPageUrl");
125                         Assert.AreEqual (false, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
126                         Assert.AreEqual ("https://help.page.url", element.HttpsHelpPageUrl.OriginalString, "HttpsHelpPageUrl");
127                         Assert.AreEqual (true, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
128                 }
129
130                 [Test]
131                 public void ServiceDebugElement_defaults () {
132                         ServiceDebugElement element = new ServiceDebugElement ();
133
134                         Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
135                         Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
136
137                         Assert.AreEqual (true, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
138                         Assert.AreEqual (null, element.HttpHelpPageUrl, "HttpHelpPageUrl");
139                         Assert.AreEqual (true, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
140                         Assert.AreEqual (null, element.HttpsHelpPageUrl, "HttpsHelpPageUrl");
141                         Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
142                 }
143
144                 [Test]
145                 public void ServiceMetadataPublishingElement () {
146                         ServiceBehaviorElement behavior = OpenConfig ();
147                         ServiceMetadataPublishingElement element = (ServiceMetadataPublishingElement) behavior [typeof (ServiceMetadataPublishingElement)];
148
149                         if (element == null)
150                                 Assert.Fail ("ServiceMetadataPublishingElement is not exist in collection.");
151
152                         Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
153                         Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
154
155                         Assert.AreEqual (true, element.HttpGetEnabled, "HttpGetEnabled");
156                         Assert.AreEqual ("http://get.url", element.HttpGetUrl.OriginalString, "HttpGetUrl");
157                         Assert.AreEqual (true, element.HttpsGetEnabled, "HttpsGetEnabled");
158                         Assert.AreEqual ("https://get.url", element.HttpsGetUrl.OriginalString, "HttpsHelpPageUrl");
159                         Assert.AreEqual ("http://external.metadata.location", element.ExternalMetadataLocation.OriginalString, "ExternalMetadataLocation");
160                         Assert.AreEqual (PolicyVersion.Policy12, element.PolicyVersion, "PolicyVersion");
161                 }
162
163                 [Test]
164                 public void ServiceMetadataPublishingElement_defaults () {
165                         ServiceMetadataPublishingElement element = new ServiceMetadataPublishingElement ();
166
167                         Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
168                         Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
169
170                         Assert.AreEqual (false, element.HttpGetEnabled, "HttpGetEnabled");
171                         Assert.AreEqual (null, element.HttpGetUrl, "HttpGetUrl");
172                         Assert.AreEqual (false, element.HttpsGetEnabled, "HttpsGetEnabled");
173                         Assert.AreEqual (null, element.HttpsGetUrl, "HttpsGetUrl");
174                         Assert.AreEqual (null, element.ExternalMetadataLocation, "ExternalMetadataLocation");
175                         Assert.AreEqual (PolicyVersion.Default, element.PolicyVersion, "PolicyVersion");
176                 }
177
178                 [Test]
179                 public void ServiceSecurityAuditElement () {
180                         ServiceBehaviorElement behavior = OpenConfig ();
181                         ServiceSecurityAuditElement element = (ServiceSecurityAuditElement) behavior [typeof (ServiceSecurityAuditElement)];
182
183                         if (element == null)
184                                 Assert.Fail ("ServiceSecurityAuditElement is not exist in collection.");
185
186                         Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
187                         Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
188
189                         Assert.AreEqual (AuditLogLocation.Application, element.AuditLogLocation, "AuditLogLocation");
190                         Assert.AreEqual (false, element.SuppressAuditFailure, "SuppressAuditFailure");
191                         Assert.AreEqual (AuditLevel.Success, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
192                         Assert.AreEqual (AuditLevel.Success, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
193                 }
194
195                 [Test]
196                 public void ServiceSecurityAuditElement_defaults () {
197                         ServiceSecurityAuditElement element = new ServiceSecurityAuditElement ();
198
199                         Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
200                         Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
201
202                         Assert.AreEqual (AuditLogLocation.Default, element.AuditLogLocation, "AuditLogLocation");
203                         Assert.AreEqual (true, element.SuppressAuditFailure, "SuppressAuditFailure");
204                         Assert.AreEqual (AuditLevel.None, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
205                         Assert.AreEqual (AuditLevel.None, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
206                 }
207
208                 [Test]
209                 public void ServiceThrottlingElement () {
210                         ServiceBehaviorElement behavior = OpenConfig ();
211                         ServiceThrottlingElement element = (ServiceThrottlingElement) behavior [typeof (ServiceThrottlingElement)];
212
213                         if (element == null)
214                                 Assert.Fail ("ServiceThrottlingElement is not exist in collection.");
215
216                         Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
217                         Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
218
219                         Assert.AreEqual (32, element.MaxConcurrentCalls, "MaxConcurrentCalls");
220                         Assert.AreEqual (20, element.MaxConcurrentSessions, "MaxConcurrentSessions");
221                         Assert.AreEqual (14, element.MaxConcurrentInstances, "MaxConcurrentInstances");
222                 }
223
224                 [Test]
225                 public void ServiceThrottlingElement_defaults () {
226                         ServiceThrottlingElement element = new ServiceThrottlingElement ();
227
228                         Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
229                         Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
230
231                         Assert.AreEqual (16, element.MaxConcurrentCalls, "MaxConcurrentCalls");
232                         Assert.AreEqual (10, element.MaxConcurrentSessions, "MaxConcurrentSessions");
233                         Assert.AreEqual (26, element.MaxConcurrentInstances, "MaxConcurrentInstances");
234                 }
235
236                 [Test]
237                 public void ServiceTimeoutsElement () {
238                         ServiceBehaviorElement behavior = OpenConfig ();
239                         ServiceTimeoutsElement element = (ServiceTimeoutsElement) behavior [typeof (ServiceTimeoutsElement)];
240
241                         if (element == null)
242                                 Assert.Fail ("ServiceTimeoutsElement is not exist in collection.");
243
244                         Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
245                         Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
246
247                         Assert.AreEqual (new TimeSpan (0, 3, 0), element.TransactionTimeout, "TransactionTimeout");
248                 }
249
250                 [Test]
251                 public void ServiceTimeoutsElement_defaults () {
252                         ServiceTimeoutsElement element = new ServiceTimeoutsElement ();
253
254                         Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
255                         Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
256
257                         Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
258                 }
259
260                 [Test]
261                 public void ServiceCredentialsElement () {
262                         ServiceBehaviorElement behavior = OpenConfig ();
263                         ServiceCredentialsElement element = (ServiceCredentialsElement) behavior [typeof (ServiceCredentialsElement)];
264
265                         if (element == null)
266                                 Assert.Fail ("ServiceCredentialsElement is not exist in collection.");
267
268                         Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
269                         Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
270
271                         Assert.AreEqual ("ServiceCredentialsType", element.Type, "Type");
272
273                         Assert.AreEqual ("FindValue", element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
274                         Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
275                         Assert.AreEqual (StoreName.Root, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
276                         Assert.AreEqual (X509FindType.FindByIssuerName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
277
278                         Assert.AreEqual ("CustomCertificateValidationType", element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
279                         Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
280                         Assert.AreEqual (X509RevocationMode.Offline, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
281                         Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
282                         Assert.AreEqual (false, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
283                         Assert.AreEqual (true, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
284
285                         Assert.AreEqual ("FindValue", element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
286                         Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
287                         Assert.AreEqual (StoreName.Root, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
288                         Assert.AreEqual (X509FindType.FindByIssuerName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
289
290                         Assert.AreEqual (UserNamePasswordValidationMode.MembershipProvider, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
291                         Assert.AreEqual (false, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
292                         Assert.AreEqual ("MembershipProviderName", element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
293                         Assert.AreEqual ("CustomUserNamePasswordValidatorType", element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
294                         Assert.AreEqual (true, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
295                         Assert.AreEqual (252, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
296                         Assert.AreEqual (new TimeSpan (0, 30, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
297
298                         Assert.AreEqual ("FindValue", element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
299                         Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
300                         Assert.AreEqual (StoreName.Root, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
301                         Assert.AreEqual (X509FindType.FindByIssuerName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
302
303                         Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
304                         Assert.AreEqual (X509CertificateValidationMode.Custom, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
305                         Assert.AreEqual (X509RevocationMode.Offline, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
306                         Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
307
308                         Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
309                         Assert.AreEqual (X509CertificateValidationMode.None, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
310                         Assert.AreEqual (X509RevocationMode.Offline, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
311                         Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
312
313                         Assert.AreEqual ("CustomCertificateValidatorType", element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
314                         Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
315                         Assert.AreEqual (X509RevocationMode.Offline, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
316                         Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
317                         Assert.AreEqual ("SalmSerializerType", element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
318                         Assert.AreEqual (true, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
319
320                         Assert.AreEqual ("FindValue", element.IssuedTokenAuthentication.KnownCertificates [0].FindValue, "IssuedTokenAuthentication.KnownCertificates[0].FindValue");
321                         Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.KnownCertificates [0].StoreLocation, "IssuedTokenAuthentication.KnownCertificates[0].StoreLocation");
322                         Assert.AreEqual (StoreName.Root, element.IssuedTokenAuthentication.KnownCertificates [0].StoreName, "IssuedTokenAuthentication.KnownCertificates[0].StoreName");
323                         Assert.AreEqual (X509FindType.FindByIssuerName, element.IssuedTokenAuthentication.KnownCertificates [0].X509FindType, "IssuedTokenAuthentication.KnownCertificates[0].X509FindType");
324
325                         Assert.AreEqual ("SecurityStateEncoderType", element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
326                 }
327
328                 [Test]
329                 public void ServiceCredentialsElement_defaults () {
330                         ServiceCredentialsElement element = new ServiceCredentialsElement ();
331
332                         Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
333                         Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
334
335                         Assert.AreEqual (String.Empty, element.Type, "Type");
336
337                         Assert.AreEqual (String.Empty, element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
338                         Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
339                         Assert.AreEqual (StoreName.My, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
340                         Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
341
342                         Assert.AreEqual (String.Empty, element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
343                         Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
344                         Assert.AreEqual (X509RevocationMode.Online, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
345                         Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
346                         Assert.AreEqual (true, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
347                         Assert.AreEqual (false, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
348
349                         Assert.AreEqual (String.Empty, element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
350                         Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
351                         Assert.AreEqual (StoreName.My, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
352                         Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
353
354                         Assert.AreEqual (UserNamePasswordValidationMode.Windows, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
355                         Assert.AreEqual (true, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
356                         Assert.AreEqual (String.Empty, element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
357                         Assert.AreEqual (String.Empty, element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
358                         Assert.AreEqual (false, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
359                         Assert.AreEqual (128, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
360                         Assert.AreEqual (new TimeSpan (0, 15, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
361
362                         Assert.AreEqual (String.Empty, element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
363                         Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
364                         Assert.AreEqual (StoreName.My, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
365                         Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
366
367                         Assert.AreEqual (String.Empty, element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
368                         Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
369                         Assert.AreEqual (X509RevocationMode.Online, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
370                         Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
371
372                         Assert.AreEqual (String.Empty, element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
373                         Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
374                         Assert.AreEqual (X509RevocationMode.Online, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
375                         Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
376
377                         Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
378                         Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
379                         Assert.AreEqual (X509RevocationMode.Online, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
380                         Assert.AreEqual (StoreLocation.LocalMachine, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
381                         Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
382                         Assert.AreEqual (false, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
383
384                         Assert.AreEqual (0, element.IssuedTokenAuthentication.KnownCertificates.Count, "IssuedTokenAuthentication.KnownCertificates.Count");
385
386                         Assert.AreEqual (String.Empty, element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
387                 }
388         }
389 }