2 // SecureConversationSecurityTokenParametersTest.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
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:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
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.
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
32 using System.Net.Security;
33 using System.IdentityModel.Selectors;
34 using System.ServiceModel;
35 using System.ServiceModel.Channels;
36 using System.ServiceModel.Description;
37 using System.ServiceModel.Security;
38 using System.ServiceModel.Security.Tokens;
39 using NUnit.Framework;
41 using Parameters = System.ServiceModel.Security.Tokens.SecureConversationSecurityTokenParameters;
43 namespace MonoTests.System.ServiceModel
46 public class SecureConversationSecurityTokenParametersTest
48 class MyParameters : Parameters
50 public MyParameters ()
54 public MyParameters (SecurityBindingElement element)
59 public MyParameters (SecurityBindingElement element,
61 ChannelProtectionRequirements requirements)
62 : base (element, cancel, requirements)
67 get { return HasAsymmetricKey; }
71 get { return SupportsClientAuthentication; }
75 get { return SupportsClientWindowsIdentity; }
79 get { return SupportsServerAuthentication; }
82 public void InitRequirement (SecurityTokenRequirement r)
84 InitializeSecurityTokenRequirement (r);
89 public void DefaultValues ()
91 MyParameters p = new MyParameters ();
92 Assert.IsNull (p.BootstrapSecurityBindingElement, "#1-1");
93 Assert.IsNotNull (p.BootstrapProtectionRequirements, "#1-2");
94 Assert.AreEqual (true, p.RequireCancellation, "#1-3");
96 Assert.AreEqual (false, p.Asym, "#1-4");
97 // they cause NRE on winfx, likely a bug.
98 //Assert.AreEqual (true, p.Client, "#1-5");
99 //Assert.AreEqual (true, p.Win, "#1-6");
100 //Assert.AreEqual (true, p.Server, "#1-7");
102 p = new MyParameters (new AsymmetricSecurityBindingElement ());
103 Assert.IsNotNull (p.BootstrapSecurityBindingElement, "#2-1");
104 Assert.IsNotNull (p.BootstrapProtectionRequirements, "#2-2");
105 Assert.AreEqual (true, p.RequireCancellation, "#2-3");
107 Assert.AreEqual (false, p.Asym, "#2-4"); // regardless of binding element.
108 Assert.AreEqual (false, p.Client, "#2-5");
109 Assert.AreEqual (false, p.Win, "#2-6");
110 Assert.AreEqual (false, p.Server, "#2-7");
112 ChannelProtectionRequirements r =
113 p.BootstrapProtectionRequirements;
114 Assert.IsTrue (r.IncomingSignatureParts.ChannelParts.IsBodyIncluded, "#3-1");
115 Assert.IsTrue (r.OutgoingSignatureParts.ChannelParts.IsBodyIncluded, "#3-2");
116 Assert.IsTrue (r.IncomingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-3");
117 Assert.IsTrue (r.OutgoingEncryptionParts.ChannelParts.IsBodyIncluded, "#3-4");
121 public void NullArgs ()
123 new Parameters ((SecurityBindingElement) null);
124 new Parameters (null, false, null);
128 [Ignore ("winfx bug")]
129 public void InitializeSecurityTokenRequirement ()
131 ServiceModelSecurityTokenRequirement r =
132 new InitiatorServiceModelSecurityTokenRequirement ();
133 SymmetricSecurityBindingElement sbe =
134 // new SymmetricSecurityBindingElement ();
135 new WSHttpBinding ().CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
136 sbe.ProtectionTokenParameters = new X509SecurityTokenParameters ();
137 // MyParameters p = new MyParameters (sbe);
138 // NRE occurs on winfx (likely a bug).
139 // p.InitRequirement (r);