ClientCredentialsTest.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // ClientCredentialsTest.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2006 Novell, Inc. http://www.novell.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.ObjectModel;
  30. using System.IdentityModel.Claims;
  31. using System.IdentityModel.Selectors;
  32. using System.Security.Principal;
  33. using System.ServiceModel;
  34. using System.ServiceModel.Channels;
  35. using System.ServiceModel.Description;
  36. using System.ServiceModel.Dispatcher;
  37. using System.ServiceModel.Security;
  38. using NUnit.Framework;
  39. namespace MonoTests.System.ServiceModel.Description
  40. {
  41. [TestFixture]
  42. public class ClientCredentialsTest
  43. {
  44. [Test]
  45. public void ClientCertificate ()
  46. {
  47. ClientCredentials c = new ClientCredentials ();
  48. Assert.AreEqual (true, c.SupportInteractive, "#1");
  49. X509CertificateInitiatorClientCredential ccert =
  50. c.ClientCertificate;
  51. Assert.IsNull (ccert.Certificate, "#2");
  52. }
  53. [Test]
  54. public void HttpDigest ()
  55. {
  56. ClientCredentials c = new ClientCredentials ();
  57. // FIXME: implement
  58. HttpDigestClientCredential http = c.HttpDigest;
  59. }
  60. [Test]
  61. public void IssuedToken ()
  62. {
  63. ClientCredentials c = new ClientCredentials ();
  64. IssuedTokenClientCredential iss = c.IssuedToken;
  65. Assert.IsNotNull (iss, "#1");
  66. Assert.AreEqual (true, iss.CacheIssuedTokens, "#2");
  67. Assert.AreEqual (SecurityKeyEntropyMode.CombinedEntropy, iss.DefaultKeyEntropyMode, "#3");
  68. Assert.AreEqual (60, iss.IssuedTokenRenewalThresholdPercentage, "#4");
  69. Assert.AreEqual (0, iss.IssuerChannelBehaviors.Count, "#5");
  70. Assert.IsNull (iss.LocalIssuerAddress, "#6");
  71. Assert.IsNull (iss.LocalIssuerBinding, "#7");
  72. Assert.AreEqual (0, iss.LocalIssuerChannelBehaviors.Count, "#8");
  73. Assert.AreEqual (TimeSpan.MaxValue, iss.MaxIssuedTokenCachingTime, "#9");
  74. }
  75. [Test]
  76. public void Peer ()
  77. {
  78. ClientCredentials c = new ClientCredentials ();
  79. // FIXME: implement
  80. PeerCredential peer = c.Peer;
  81. }
  82. [Test]
  83. public void ServiceCertificate ()
  84. {
  85. ClientCredentials c = new ClientCredentials ();
  86. // FIXME: implement
  87. X509CertificateRecipientClientCredential scert =
  88. c.ServiceCertificate;
  89. }
  90. [Test]
  91. public void UserName ()
  92. {
  93. ClientCredentials c = new ClientCredentials ();
  94. // FIXME: implement
  95. UserNamePasswordClientCredential userpass = c.UserName;
  96. }
  97. [Test]
  98. public void Windows ()
  99. {
  100. ClientCredentials c = new ClientCredentials ();
  101. WindowsClientCredential win = c.Windows;
  102. Assert.IsNotNull (win.ClientCredential, "#1");
  103. Assert.IsTrue (win.AllowNtlm, "#2");
  104. Assert.AreEqual (TokenImpersonationLevel.Identification, win.AllowedImpersonationLevel, "#3");
  105. }
  106. }
  107. }