ServiceBehaviorElementTest.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. //
  2. // ServiceBehaviorElementTest.cs
  3. //
  4. // Author:
  5. // Igor Zelmanovich <[email protected]>
  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. using System;
  29. using System.Collections.Generic;
  30. using System.Text;
  31. using NUnit.Framework;
  32. using System.ServiceModel.Configuration;
  33. using System.ServiceModel.Description;
  34. using System.Configuration;
  35. using System.ServiceModel;
  36. using System.Security.Cryptography.X509Certificates;
  37. using System.ServiceModel.Security;
  38. namespace MonoTests.System.ServiceModel.Configuration
  39. {
  40. [TestFixture]
  41. public class ServiceBehaviorElementTest
  42. {
  43. ServiceBehaviorElement OpenConfig () {
  44. ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/serviceBehaviors").GetSectionGroup ("system.serviceModel");
  45. return config.Behaviors.ServiceBehaviors [0];
  46. }
  47. [Test]
  48. public void ServiceAuthorizationElement () {
  49. ServiceBehaviorElement behavior = OpenConfig ();
  50. ServiceAuthorizationElement serviceAuthorization = (ServiceAuthorizationElement) behavior [typeof (ServiceAuthorizationElement)];
  51. if (serviceAuthorization == null)
  52. Assert.Fail ("ServiceAuthorizationElement is not exist in collection.");
  53. Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
  54. Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
  55. Assert.AreEqual ("RoleProvider", serviceAuthorization.RoleProviderName, "RoleProviderName");
  56. Assert.AreEqual (PrincipalPermissionMode.UseAspNetRoles, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
  57. Assert.AreEqual (true, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
  58. Assert.AreEqual ("SerAuthManagType", serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
  59. Assert.AreEqual (2, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
  60. Assert.AreEqual ("PolicyType1", serviceAuthorization.AuthorizationPolicies [0].PolicyType, "AuthorizationPolicies[0].PolicyType");
  61. Assert.AreEqual ("PolicyType2", serviceAuthorization.AuthorizationPolicies [1].PolicyType, "AuthorizationPolicies[1].PolicyType");
  62. }
  63. [Test]
  64. public void ServiceAuthorizationElement_default () {
  65. ServiceAuthorizationElement serviceAuthorization = new ServiceAuthorizationElement ();
  66. Assert.AreEqual (typeof (ServiceAuthorizationBehavior), serviceAuthorization.BehaviorType, "BehaviorType");
  67. Assert.AreEqual ("serviceAuthorization", serviceAuthorization.ConfigurationElementName, "ConfigurationElementName");
  68. Assert.AreEqual (String.Empty, serviceAuthorization.RoleProviderName, "RoleProviderName");
  69. Assert.AreEqual (PrincipalPermissionMode.UseWindowsGroups, serviceAuthorization.PrincipalPermissionMode, "PrincipalPermissionMode");
  70. Assert.AreEqual (false, serviceAuthorization.ImpersonateCallerForAllOperations, "ImpersonateCallerForAllOperations");
  71. Assert.AreEqual (String.Empty, serviceAuthorization.ServiceAuthorizationManagerType, "ServiceAuthorizationManagerType");
  72. Assert.AreEqual (0, serviceAuthorization.AuthorizationPolicies.Count, "AuthorizationPolicies.Count");
  73. }
  74. [Test]
  75. public void DataContractSerializerElement () {
  76. ServiceBehaviorElement behavior = OpenConfig ();
  77. DataContractSerializerElement element = (DataContractSerializerElement) behavior [typeof (DataContractSerializerElement)];
  78. if (element == null)
  79. Assert.Fail ("DataContractSerializerElement is not exist in collection.");
  80. Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
  81. Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
  82. Assert.AreEqual (true, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
  83. Assert.AreEqual (32768, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
  84. }
  85. [Test]
  86. public void DataContractSerializerElement_defaults () {
  87. DataContractSerializerElement element = new DataContractSerializerElement ();
  88. Assert.AreEqual ("System.ServiceModel.Dispatcher.DataContractSerializerServiceBehavior", element.BehaviorType.FullName, "BehaviorType");
  89. Assert.AreEqual ("dataContractSerializer", element.ConfigurationElementName, "ConfigurationElementName");
  90. Assert.AreEqual (false, element.IgnoreExtensionDataObject, "IgnoreExtensionDataObject");
  91. Assert.AreEqual (65536, element.MaxItemsInObjectGraph, "MaxItemsInObjectGraph");
  92. }
  93. [Test]
  94. public void ServiceDebugElement () {
  95. ServiceBehaviorElement behavior = OpenConfig ();
  96. ServiceDebugElement element = (ServiceDebugElement) behavior [typeof (ServiceDebugElement)];
  97. if (element == null)
  98. Assert.Fail ("ServiceDebugElement is not exist in collection.");
  99. Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
  100. Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
  101. Assert.AreEqual (false, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
  102. Assert.AreEqual ("http://help.page.url", element.HttpHelpPageUrl.OriginalString, "HttpHelpPageUrl");
  103. Assert.AreEqual (false, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
  104. Assert.AreEqual ("https://help.page.url", element.HttpsHelpPageUrl.OriginalString, "HttpsHelpPageUrl");
  105. Assert.AreEqual (true, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
  106. }
  107. [Test]
  108. public void ServiceDebugElement_defaults () {
  109. ServiceDebugElement element = new ServiceDebugElement ();
  110. Assert.AreEqual (typeof (ServiceDebugBehavior), element.BehaviorType, "BehaviorType");
  111. Assert.AreEqual ("serviceDebug", element.ConfigurationElementName, "ConfigurationElementName");
  112. Assert.AreEqual (true, element.HttpHelpPageEnabled, "HttpHelpPageEnabled");
  113. Assert.AreEqual (null, element.HttpHelpPageUrl, "HttpHelpPageUrl");
  114. Assert.AreEqual (true, element.HttpsHelpPageEnabled, "HttpsHelpPageEnabled");
  115. Assert.AreEqual (null, element.HttpsHelpPageUrl, "HttpsHelpPageUrl");
  116. Assert.AreEqual (false, element.IncludeExceptionDetailInFaults, "IncludeExceptionDetailInFaults");
  117. }
  118. [Test]
  119. public void ServiceMetadataPublishingElement () {
  120. ServiceBehaviorElement behavior = OpenConfig ();
  121. ServiceMetadataPublishingElement element = (ServiceMetadataPublishingElement) behavior [typeof (ServiceMetadataPublishingElement)];
  122. if (element == null)
  123. Assert.Fail ("ServiceMetadataPublishingElement is not exist in collection.");
  124. Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
  125. Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
  126. Assert.AreEqual (true, element.HttpGetEnabled, "HttpGetEnabled");
  127. Assert.AreEqual ("http://get.url", element.HttpGetUrl.OriginalString, "HttpGetUrl");
  128. Assert.AreEqual (true, element.HttpsGetEnabled, "HttpsGetEnabled");
  129. Assert.AreEqual ("https://get.url", element.HttpsGetUrl.OriginalString, "HttpsHelpPageUrl");
  130. Assert.AreEqual ("http://external.metadata.location", element.ExternalMetadataLocation.OriginalString, "ExternalMetadataLocation");
  131. Assert.AreEqual (PolicyVersion.Policy12, element.PolicyVersion, "PolicyVersion");
  132. }
  133. [Test]
  134. public void ServiceMetadataPublishingElement_defaults () {
  135. ServiceMetadataPublishingElement element = new ServiceMetadataPublishingElement ();
  136. Assert.AreEqual (typeof (ServiceMetadataBehavior), element.BehaviorType, "BehaviorType");
  137. Assert.AreEqual ("serviceMetadata", element.ConfigurationElementName, "ConfigurationElementName");
  138. Assert.AreEqual (false, element.HttpGetEnabled, "HttpGetEnabled");
  139. Assert.AreEqual (null, element.HttpGetUrl, "HttpGetUrl");
  140. Assert.AreEqual (false, element.HttpsGetEnabled, "HttpsGetEnabled");
  141. Assert.AreEqual (null, element.HttpsGetUrl, "HttpsGetUrl");
  142. Assert.AreEqual (null, element.ExternalMetadataLocation, "ExternalMetadataLocation");
  143. Assert.AreEqual (PolicyVersion.Default, element.PolicyVersion, "PolicyVersion");
  144. }
  145. [Test]
  146. public void ServiceSecurityAuditElement () {
  147. ServiceBehaviorElement behavior = OpenConfig ();
  148. ServiceSecurityAuditElement element = (ServiceSecurityAuditElement) behavior [typeof (ServiceSecurityAuditElement)];
  149. if (element == null)
  150. Assert.Fail ("ServiceSecurityAuditElement is not exist in collection.");
  151. Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
  152. Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
  153. Assert.AreEqual (AuditLogLocation.Application, element.AuditLogLocation, "AuditLogLocation");
  154. Assert.AreEqual (false, element.SuppressAuditFailure, "SuppressAuditFailure");
  155. Assert.AreEqual (AuditLevel.Success, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
  156. Assert.AreEqual (AuditLevel.Success, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
  157. }
  158. [Test]
  159. public void ServiceSecurityAuditElement_defaults () {
  160. ServiceSecurityAuditElement element = new ServiceSecurityAuditElement ();
  161. Assert.AreEqual (typeof (ServiceSecurityAuditBehavior), element.BehaviorType, "BehaviorType");
  162. Assert.AreEqual ("serviceSecurityAudit", element.ConfigurationElementName, "ConfigurationElementName");
  163. Assert.AreEqual (AuditLogLocation.Default, element.AuditLogLocation, "AuditLogLocation");
  164. Assert.AreEqual (true, element.SuppressAuditFailure, "SuppressAuditFailure");
  165. Assert.AreEqual (AuditLevel.None, element.ServiceAuthorizationAuditLevel, "ServiceAuthorizationAuditLevel");
  166. Assert.AreEqual (AuditLevel.None, element.MessageAuthenticationAuditLevel, "MessageAuthenticationAuditLevel");
  167. }
  168. [Test]
  169. public void ServiceThrottlingElement () {
  170. ServiceBehaviorElement behavior = OpenConfig ();
  171. ServiceThrottlingElement element = (ServiceThrottlingElement) behavior [typeof (ServiceThrottlingElement)];
  172. if (element == null)
  173. Assert.Fail ("ServiceThrottlingElement is not exist in collection.");
  174. Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
  175. Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
  176. Assert.AreEqual (32, element.MaxConcurrentCalls, "MaxConcurrentCalls");
  177. Assert.AreEqual (20, element.MaxConcurrentSessions, "MaxConcurrentSessions");
  178. Assert.AreEqual (14, element.MaxConcurrentInstances, "MaxConcurrentInstances");
  179. }
  180. [Test]
  181. public void ServiceThrottlingElement_defaults () {
  182. ServiceThrottlingElement element = new ServiceThrottlingElement ();
  183. Assert.AreEqual (typeof (ServiceThrottlingBehavior), element.BehaviorType, "BehaviorType");
  184. Assert.AreEqual ("serviceThrottling", element.ConfigurationElementName, "ConfigurationElementName");
  185. Assert.AreEqual (16, element.MaxConcurrentCalls, "MaxConcurrentCalls");
  186. Assert.AreEqual (10, element.MaxConcurrentSessions, "MaxConcurrentSessions");
  187. Assert.AreEqual (26, element.MaxConcurrentInstances, "MaxConcurrentInstances");
  188. }
  189. [Test]
  190. public void ServiceTimeoutsElement () {
  191. ServiceBehaviorElement behavior = OpenConfig ();
  192. ServiceTimeoutsElement element = (ServiceTimeoutsElement) behavior [typeof (ServiceTimeoutsElement)];
  193. if (element == null)
  194. Assert.Fail ("ServiceTimeoutsElement is not exist in collection.");
  195. Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
  196. Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
  197. Assert.AreEqual (new TimeSpan (0, 3, 0), element.TransactionTimeout, "TransactionTimeout");
  198. }
  199. [Test]
  200. public void ServiceTimeoutsElement_defaults () {
  201. ServiceTimeoutsElement element = new ServiceTimeoutsElement ();
  202. Assert.AreEqual ("System.ServiceModel.Description.ServiceTimeoutsBehavior", element.BehaviorType.FullName, "BehaviorType");
  203. Assert.AreEqual ("serviceTimeouts", element.ConfigurationElementName, "ConfigurationElementName");
  204. Assert.AreEqual (new TimeSpan (0, 0, 0), element.TransactionTimeout, "TransactionTimeout");
  205. }
  206. [Test]
  207. public void ServiceCredentialsElement () {
  208. ServiceBehaviorElement behavior = OpenConfig ();
  209. ServiceCredentialsElement element = (ServiceCredentialsElement) behavior [typeof (ServiceCredentialsElement)];
  210. if (element == null)
  211. Assert.Fail ("ServiceCredentialsElement is not exist in collection.");
  212. Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
  213. Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
  214. Assert.AreEqual ("ServiceCredentialsType", element.Type, "Type");
  215. Assert.AreEqual ("FindValue", element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
  216. Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
  217. Assert.AreEqual (StoreName.Root, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
  218. Assert.AreEqual (X509FindType.FindByIssuerName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
  219. Assert.AreEqual ("CustomCertificateValidationType", element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
  220. Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
  221. Assert.AreEqual (X509RevocationMode.Offline, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
  222. Assert.AreEqual (StoreLocation.CurrentUser, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
  223. Assert.AreEqual (false, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
  224. Assert.AreEqual (true, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
  225. Assert.AreEqual ("FindValue", element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
  226. Assert.AreEqual (StoreLocation.CurrentUser, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
  227. Assert.AreEqual (StoreName.Root, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
  228. Assert.AreEqual (X509FindType.FindByIssuerName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
  229. Assert.AreEqual (UserNamePasswordValidationMode.MembershipProvider, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
  230. Assert.AreEqual (false, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
  231. Assert.AreEqual ("MembershipProviderName", element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
  232. Assert.AreEqual ("CustomUserNamePasswordValidatorType", element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
  233. Assert.AreEqual (true, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
  234. Assert.AreEqual (252, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
  235. Assert.AreEqual (new TimeSpan (0, 30, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
  236. Assert.AreEqual ("FindValue", element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
  237. Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
  238. Assert.AreEqual (StoreName.Root, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
  239. Assert.AreEqual (X509FindType.FindByIssuerName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
  240. Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
  241. Assert.AreEqual (X509CertificateValidationMode.Custom, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
  242. Assert.AreEqual (X509RevocationMode.Offline, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
  243. Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
  244. Assert.AreEqual ("CustomCertificateValidatorType", element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
  245. Assert.AreEqual (X509CertificateValidationMode.None, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
  246. Assert.AreEqual (X509RevocationMode.Offline, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
  247. Assert.AreEqual (StoreLocation.LocalMachine, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
  248. Assert.AreEqual ("CustomCertificateValidatorType", element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
  249. Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
  250. Assert.AreEqual (X509RevocationMode.Offline, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
  251. Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
  252. Assert.AreEqual ("SalmSerializerType", element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
  253. Assert.AreEqual (true, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
  254. Assert.AreEqual ("FindValue", element.IssuedTokenAuthentication.KnownCertificates [0].FindValue, "IssuedTokenAuthentication.KnownCertificates[0].FindValue");
  255. Assert.AreEqual (StoreLocation.CurrentUser, element.IssuedTokenAuthentication.KnownCertificates [0].StoreLocation, "IssuedTokenAuthentication.KnownCertificates[0].StoreLocation");
  256. Assert.AreEqual (StoreName.Root, element.IssuedTokenAuthentication.KnownCertificates [0].StoreName, "IssuedTokenAuthentication.KnownCertificates[0].StoreName");
  257. Assert.AreEqual (X509FindType.FindByIssuerName, element.IssuedTokenAuthentication.KnownCertificates [0].X509FindType, "IssuedTokenAuthentication.KnownCertificates[0].X509FindType");
  258. Assert.AreEqual ("SecurityStateEncoderType", element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
  259. }
  260. [Test]
  261. public void ServiceCredentialsElement_defaults () {
  262. ServiceCredentialsElement element = new ServiceCredentialsElement ();
  263. Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
  264. Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");
  265. Assert.AreEqual (String.Empty, element.Type, "Type");
  266. Assert.AreEqual (String.Empty, element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
  267. Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
  268. Assert.AreEqual (StoreName.My, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
  269. Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");
  270. Assert.AreEqual (String.Empty, element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
  271. Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
  272. Assert.AreEqual (X509RevocationMode.Online, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
  273. Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
  274. Assert.AreEqual (true, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
  275. Assert.AreEqual (false, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");
  276. Assert.AreEqual (String.Empty, element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
  277. Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
  278. Assert.AreEqual (StoreName.My, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
  279. Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");
  280. Assert.AreEqual (UserNamePasswordValidationMode.Windows, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
  281. Assert.AreEqual (true, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
  282. Assert.AreEqual (String.Empty, element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
  283. Assert.AreEqual (String.Empty, element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
  284. Assert.AreEqual (false, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
  285. Assert.AreEqual (128, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
  286. Assert.AreEqual (new TimeSpan (0, 15, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");
  287. Assert.AreEqual (String.Empty, element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
  288. Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
  289. Assert.AreEqual (StoreName.My, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
  290. Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");
  291. Assert.AreEqual (String.Empty, element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
  292. Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
  293. Assert.AreEqual (X509RevocationMode.Online, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
  294. Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");
  295. Assert.AreEqual (String.Empty, element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
  296. Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
  297. Assert.AreEqual (X509RevocationMode.Online, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
  298. Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");
  299. Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
  300. Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
  301. Assert.AreEqual (X509RevocationMode.Online, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
  302. Assert.AreEqual (StoreLocation.LocalMachine, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
  303. Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
  304. Assert.AreEqual (false, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");
  305. Assert.AreEqual (0, element.IssuedTokenAuthentication.KnownCertificates.Count, "IssuedTokenAuthentication.KnownCertificates.Count");
  306. Assert.AreEqual (String.Empty, element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
  307. }
  308. }
  309. }