1 //
2 // WSHttpBindingTest.cs
3 //
4 // Author:
5 //	Atsushi Enomoto <atsushi@ximian.com>
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 #if !MOBILE && !XAMMAC_4_5
29 using System;
30 using System.Collections.ObjectModel;
31 using System.Net;
32 using System.Net.Security;
33 using System.IdentityModel.Claims;
34 using System.IdentityModel.Selectors;
35 using System.IdentityModel.Tokens;
36 using System.ServiceModel;
37 using System.ServiceModel.Channels;
38 using System.ServiceModel.Security;
39 using System.ServiceModel.Security.Tokens;
40 using NUnit.Framework;
41 
42 namespace MonoTests.System.ServiceModel
43 {
44 	[TestFixture]
45 	public class WSHttpBindingTest
46 	{
47 		[Test]
DefaultValues()48 		public void DefaultValues ()
49 		{
50 			WSHttpBinding b= new WSHttpBinding ();
51 			// common tests
52 			DefaultValues (b, "http");
53 
54 			// WSHttpSecurity
55 			WSHttpSecurity sec = b.Security;
56 			Assert.IsNotNull (sec, "#2-1");
57 			Assert.AreEqual (SecurityMode.Message, sec.Mode, "#2-2");
58 			// Security.Message
59 			NonDualMessageSecurityOverHttp msg = sec.Message;
60 			Assert.IsNotNull (msg, "#2-3");
61 			Assert.AreEqual (true, msg.EstablishSecurityContext, "#2-3-1");
62 			Assert.AreEqual (SecurityAlgorithmSuite.Default,
63 					 msg.AlgorithmSuite, "#2-3-2");
64 			// it is not worthy of test, just for checking default value.
65 			Assert.AreEqual (MessageCredentialType.Windows,
66 					 msg.ClientCredentialType, "#2-3-3");
67 			Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
68 			// FIXME: test Security.Transport
69 			Assert.IsNotNull (sec.Transport, "#2-4");
70 
71 			// Binding elements
72 
73 			BindingElementCollection bec = b.CreateBindingElements ();
74 			Assert.AreEqual (4, bec.Count, "#5-1");
75 			Assert.AreEqual (typeof (TransactionFlowBindingElement),
76 				bec [0].GetType (), "#5-2");
77 			Assert.AreEqual (typeof (SymmetricSecurityBindingElement),
78 				bec [1].GetType (), "#5-3");
79 			Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
80 				bec [2].GetType (), "#5-4");
81 			Assert.AreEqual (typeof (HttpTransportBindingElement),
82 				bec [3].GetType (), "#5-5");
83 		}
84 
85 		[Test]
DefaultValuesSecurityModeTransport()86 		public void DefaultValuesSecurityModeTransport ()
87 		{
88 			WSHttpBinding b = new WSHttpBinding (SecurityMode.Transport);
89 			// common tests.
90 			DefaultValues (b, "https");
91 
92 			// WSHttpSecurity
93 			WSHttpSecurity sec = b.Security;
94 			Assert.IsNotNull (sec, "#2-1");
95 			Assert.AreEqual (SecurityMode.Transport, sec.Mode, "#2-2");
96 			// Security.Message
97 			NonDualMessageSecurityOverHttp msg = sec.Message;
98 			Assert.IsNotNull (msg, "#2-3");
99 			Assert.AreEqual (true, msg.EstablishSecurityContext, "#2-3-1");
100 			Assert.AreEqual (SecurityAlgorithmSuite.Default,
101 					 msg.AlgorithmSuite, "#2-3-2");
102 			// it is not worthy of test, just for checking default value.
103 			Assert.AreEqual (MessageCredentialType.Windows,
104 					 msg.ClientCredentialType, "#2-3-3");
105 			Assert.AreEqual (true, msg.NegotiateServiceCredential, "#2-3-4");
106 			// FIXME: test Security.Transport
107 			Assert.IsNotNull (sec.Transport, "#2-4");
108 
109 			// Binding elements
110 			BindingElementCollection bec = b.CreateBindingElements ();
111 			Assert.AreEqual (3, bec.Count, "#5-1");
112 			Assert.AreEqual (typeof (TransactionFlowBindingElement),
113 				bec [0].GetType (), "#5-2");
114 			Assert.AreEqual (typeof (TextMessageEncodingBindingElement),
115 				bec [1].GetType (), "#5-3");
116 			Assert.AreEqual (typeof (HttpsTransportBindingElement),
117 				bec [2].GetType (), "#5-4");
118 		}
119 
DefaultValues(WSHttpBinding b, string scheme)120 		void DefaultValues (WSHttpBinding b, string scheme)
121 		{
122 			Assert.AreEqual (false, b.BypassProxyOnLocal, "#1");
123 			Assert.AreEqual (HostNameComparisonMode.StrongWildcard,
124 				b.HostNameComparisonMode, "#2");
125 			Assert.AreEqual (0x80000, b.MaxBufferPoolSize, "#3");
126 			Assert.AreEqual (0x10000, b.MaxReceivedMessageSize, "#5");
127 			Assert.AreEqual (WSMessageEncoding.Text, b.MessageEncoding, "#6");
128 			Assert.IsNull (b.ProxyAddress, "#7");
129 			// FIXME: test b.ReaderQuotas
130 			Assert.AreEqual (scheme, b.Scheme, "#8");
131 			Assert.AreEqual (EnvelopeVersion.Soap12, b.EnvelopeVersion, "#9");
132 			Assert.AreEqual (65001, b.TextEncoding.CodePage, "#10"); // utf-8
133 			Assert.AreEqual (false, b.TransactionFlow, "#11");
134 			Assert.AreEqual (true, b.UseDefaultWebProxy, "#12");
135 			Assert.AreEqual (false, b.AllowCookies, "#13");
136 			Assert.AreEqual (MessageVersion.Default, b.MessageVersion, "#14");
137 			Assert.IsNotNull (b.ReliableSession, "#15");
138 		}
139 
140 		[Test]
DefaultMessageEncoding()141 		public void DefaultMessageEncoding ()
142 		{
143 			WSHttpBinding b = new WSHttpBinding ();
144 			foreach (BindingElement be in b.CreateBindingElements ()) {
145 				MessageEncodingBindingElement mbe =
146 					be as MessageEncodingBindingElement;
147 				if (mbe == null)
148 					continue;
149 				MessageEncoderFactory f = mbe.CreateMessageEncoderFactory ();
150 				MessageEncoder e = f.Encoder;
151 
152 				Assert.AreEqual (typeof (TextMessageEncodingBindingElement), mbe.GetType (), "#1-1");
153 				Assert.AreEqual (MessageVersion.Default, f.MessageVersion, "#2-1");
154 				Assert.AreEqual ("application/soap+xml; charset=utf-8", e.ContentType, "#3-1");
155 				Assert.AreEqual ("application/soap+xml", e.MediaType, "#3-2");
156 				return;
157 			}
158 			Assert.Fail ("No message encodiing binding element.");
159 		}
160 
161 		[Test]
DefaultHttpTransport()162 		public void DefaultHttpTransport ()
163 		{
164 			WSHttpBinding b = new WSHttpBinding ();
165 			foreach (BindingElement be in b.CreateBindingElements ()) {
166 				HttpTransportBindingElement tbe =
167 					be as HttpTransportBindingElement;
168 				if (tbe == null)
169 					continue;
170 
171 				Assert.AreEqual (false, tbe.AllowCookies, "#1");
172 				Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.AuthenticationScheme, "#2");
173 				Assert.AreEqual (false, tbe.BypassProxyOnLocal, "#3");
174 				Assert.AreEqual (HostNameComparisonMode.StrongWildcard, tbe.HostNameComparisonMode, "#4");
175 				Assert.AreEqual (true, tbe.KeepAliveEnabled, "#5");
176 				Assert.AreEqual (false, tbe.ManualAddressing, "#6");
177 				Assert.AreEqual (0x80000, tbe.MaxBufferPoolSize, "#7");
178 				Assert.AreEqual (0x10000, tbe.MaxBufferSize, "#8");
179 				Assert.AreEqual (0x10000, tbe.MaxReceivedMessageSize, "#9");
180 				Assert.IsNull (tbe.ProxyAddress, "#10");
181 				Assert.AreEqual (AuthenticationSchemes.Anonymous, tbe.ProxyAuthenticationScheme, "#11");
182 				Assert.AreEqual ("", tbe.Realm, "#12");
183 				Assert.AreEqual (TransferMode.Buffered, tbe.TransferMode, "#13");
184 				Assert.AreEqual (true, tbe.UseDefaultWebProxy, "#14");
185 
186 				return;
187 			}
188 			Assert.Fail ("No transport binding element.");
189 		}
190 
191 		[Test]
DefaultTransactionFlow()192 		public void DefaultTransactionFlow ()
193 		{
194 			WSHttpBinding b = new WSHttpBinding ();
195 			foreach (BindingElement be in b.CreateBindingElements ()) {
196 				TransactionFlowBindingElement tbe =
197 					be as TransactionFlowBindingElement;
198 				if (tbe == null)
199 					continue;
200 
201 				Assert.AreEqual (TransactionProtocol.WSAtomicTransactionOctober2004,
202 					tbe.TransactionProtocol, "#1");
203 
204 				return;
205 			}
206 			Assert.Fail ("No transaction flow binding element.");
207 		}
208 
209 		[Test]
CreateMessageSecurity()210 		public void CreateMessageSecurity ()
211 		{
212 			Assert.IsNull (new MyWSBinding (SecurityMode.None).CreateMessageSecurityEx (), "None");
213 			Assert.IsNotNull (new MyWSBinding (SecurityMode.Message).CreateMessageSecurityEx (), "Message");
214 			Assert.IsNull (new MyWSBinding (SecurityMode.Transport).CreateMessageSecurityEx (), "Transport");
215 		}
216 
217 		[Test]
DefaultMessageSecurity()218 		public void DefaultMessageSecurity ()
219 		{
220 			WSHttpBinding b = new WSHttpBinding ();
221 			SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
222 			Assert.IsNotNull (sbe, "#0");
223 
224 			SecureConversationSecurityTokenParameters p =
225 				sbe.ProtectionTokenParameters as SecureConversationSecurityTokenParameters;
226 			Assert.IsNotNull (p, "#1");
227 			SymmetricSecurityBindingElement scbe =
228 				p.BootstrapSecurityBindingElement as SymmetricSecurityBindingElement;
229 			Assert.IsNotNull (scbe, "#1.1");
230 			// since the default w/o SecureConv is SSPI ...
231 			Assert.IsTrue (scbe.ProtectionTokenParameters is SspiSecurityTokenParameters, "#1.2");
232 
233 			Assert.AreEqual (SecurityAlgorithmSuite.Default,
234 				sbe.DefaultAlgorithmSuite, "#2");
235 
236 			SupportingTokenParameters s =
237 				sbe.EndpointSupportingTokenParameters;
238 			Assert.IsNotNull (s, "#3");
239 			Assert.AreEqual (0, s.Endorsing.Count, "#3-1");
240 			Assert.AreEqual (0, s.Signed.Count, "#3-2");
241 			Assert.AreEqual (0, s.SignedEndorsing.Count, "#3-3");
242 			Assert.AreEqual (0, s.SignedEncrypted.Count, "#3-4");
243 
244 			Assert.AreEqual (0, sbe.OperationSupportingTokenParameters.Count, "#4");
245 
246 			s = sbe.OptionalEndpointSupportingTokenParameters;
247 			Assert.IsNotNull (s, "#5");
248 			Assert.AreEqual (0, s.Endorsing.Count, "#5-1");
249 			Assert.AreEqual (0, s.Signed.Count, "#5-2");
250 			Assert.AreEqual (0, s.SignedEndorsing.Count, "#5-3");
251 			Assert.AreEqual (0, s.SignedEncrypted.Count, "#5-4");
252 			Assert.AreEqual (0, sbe.OptionalOperationSupportingTokenParameters.Count, "#6");
253 		}
254 
255 		[Test]
MessageSecurityNoSecureConversation()256 		public void MessageSecurityNoSecureConversation ()
257 		{
258 			WSHttpBinding b = new WSHttpBinding ();
259 			b.Security.Message.EstablishSecurityContext = false;
260 			SymmetricSecurityBindingElement sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
261 			Assert.IsNotNull (sbe, "#0");
262 
263 			Assert.AreEqual (
264 				typeof (SspiSecurityTokenParameters),
265 				sbe.ProtectionTokenParameters.GetType (), "#1");
266 			// no worthy to check SSPI security as we never support it.
267 
268 			b.Security.Message.ClientCredentialType = MessageCredentialType.None;
269 			sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
270 			SslSecurityTokenParameters ssltp =
271 				sbe.ProtectionTokenParameters
272 				as SslSecurityTokenParameters;
273 			Assert.IsNotNull(ssltp, "#2-1");
274 			Assert.AreEqual (true, ssltp.RequireCancellation, "#2-2");
275 			Assert.AreEqual (false, ssltp.RequireClientCertificate, "#2-3");
276 
277 			b.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
278 			sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
279 			ssltp = sbe.ProtectionTokenParameters as SslSecurityTokenParameters;
280 			Assert.IsNotNull(ssltp, "#3-1");
281 
282 			// No NegotiateServiceCredential modes ...
283 
284 			b.Security.Message.NegotiateServiceCredential = false;
285 			b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
286 			sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
287 			KerberosSecurityTokenParameters ktp =
288 				sbe.ProtectionTokenParameters
289 				as KerberosSecurityTokenParameters;
290 			Assert.IsNotNull (ktp, "#4-1");
291 			// no worthy of testing windows-only Kerberos stuff
292 
293 			b.Security.Message.ClientCredentialType = MessageCredentialType.None;
294 			sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
295 			X509SecurityTokenParameters x509tp =
296 				sbe.ProtectionTokenParameters
297 				as X509SecurityTokenParameters;
298 			Assert.IsNotNull (x509tp, "#5-1");
299 			Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#5-2");
300 			Assert.AreEqual (SecurityTokenInclusionMode.Never, x509tp.InclusionMode, "#5-3");
301 
302 			b.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
303 			sbe = b.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
304 			Assert.AreEqual (1, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#6-0");
305 			x509tp = sbe.EndpointSupportingTokenParameters.Endorsing [0] as X509SecurityTokenParameters;
306 			Assert.IsNotNull (x509tp, "#6-1");
307 			Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#6-2");
308 			Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient, x509tp.InclusionMode, "#6-3");
309 			Assert.AreEqual (false, x509tp.RequireDerivedKeys, "#6-4");
310 			x509tp = sbe.ProtectionTokenParameters as X509SecurityTokenParameters;
311 			Assert.IsNotNull (x509tp, "#7-1");
312 			Assert.AreEqual (X509KeyIdentifierClauseType.Thumbprint, x509tp.X509ReferenceStyle, "#7-2");
313 			Assert.AreEqual (SecurityTokenInclusionMode.Never, x509tp.InclusionMode, "#7-3");
314 			Assert.AreEqual (true, x509tp.RequireDerivedKeys, "#7-4");
315 			Assert.AreEqual (true, sbe.RequireSignatureConfirmation, "#8");
316 		}
317 
318 		[Test]
MessageSecurityCertificateNego()319 		public void MessageSecurityCertificateNego ()
320 		{
321 			WSHttpBinding binding = new WSHttpBinding ();
322 			binding.Security.Message.ClientCredentialType =
323 				MessageCredentialType.Certificate;
324 			SymmetricSecurityBindingElement sbe =
325 				binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
326 			Assert.IsNotNull (sbe, "#1");
327 			Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
328 
329 			SecureConversationSecurityTokenParameters sp =
330 				sbe.ProtectionTokenParameters
331 				as SecureConversationSecurityTokenParameters;
332 			Assert.IsNotNull (sp, "#2");
333 			SymmetricSecurityBindingElement spbe =
334 				sp.BootstrapSecurityBindingElement
335 				as SymmetricSecurityBindingElement;
336 			Assert.IsNotNull (spbe, "#3");
337 			SslSecurityTokenParameters p =
338 				spbe.ProtectionTokenParameters
339 				as SslSecurityTokenParameters;
340 			Assert.IsNotNull (p, "#4");
341 			Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
342 					 p.ReferenceStyle, "#5");
343 			Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
344 					 p.InclusionMode, "#6");
345 		}
346 
347 		[Test]
MessageSecuritySPNego()348 		public void MessageSecuritySPNego ()
349 		{
350 			WSHttpBinding binding = new WSHttpBinding ();
351 			SymmetricSecurityBindingElement sbe =
352 				binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
353 			Assert.IsNotNull (sbe, "#1");
354 			Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
355 
356 			SecureConversationSecurityTokenParameters sp =
357 				sbe.ProtectionTokenParameters
358 				as SecureConversationSecurityTokenParameters;
359 			Assert.IsNotNull (sp, "#2");
360 			SymmetricSecurityBindingElement spbe =
361 				sp.BootstrapSecurityBindingElement
362 				as SymmetricSecurityBindingElement;
363 			Assert.IsNotNull (spbe, "#3");
364 			SspiSecurityTokenParameters p =
365 				spbe.ProtectionTokenParameters
366 				as SspiSecurityTokenParameters;
367 			Assert.IsNotNull (p, "#4");
368 			Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
369 					 p.ReferenceStyle, "#5");
370 			Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
371 					 p.InclusionMode, "#6");
372 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Signed.Count, "#7");
373 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#8");
374 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#9");
375 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#10");
376 			Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.Signed.Count, "#11");
377 			Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#12");
378 			Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.Endorsing.Count, "#13");
379 			Assert.AreEqual (0, spbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#14");
380 
381 			Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.Signed.Count, "#17");
382 			Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.SignedEncrypted.Count, "#18");
383 			Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.Endorsing.Count, "#19");
384 			Assert.AreEqual (0, sbe.OptionalEndpointSupportingTokenParameters.SignedEndorsing.Count, "#110");
385 			Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.Signed.Count, "#21");
386 			Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.SignedEncrypted.Count, "#22");
387 			Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.Endorsing.Count, "#23");
388 			Assert.AreEqual (0, spbe.OptionalEndpointSupportingTokenParameters.SignedEndorsing.Count, "#24");
389 		}
390 
391 		[Test]
MessageSecurityUserName()392 		public void MessageSecurityUserName ()
393 		{
394 			WSHttpBinding binding = new WSHttpBinding ();
395 			binding.Security.Message.NegotiateServiceCredential = false;
396 			binding.Security.Message.EstablishSecurityContext = false;
397 			binding.Security.Message.ClientCredentialType =
398 				MessageCredentialType.UserName;
399 			SymmetricSecurityBindingElement sbe =
400 				binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
401 			Assert.IsNotNull (sbe, "#1");
402 			Assert.AreEqual (false, sbe.RequireSignatureConfirmation, "#1-2");
403 
404 			X509SecurityTokenParameters sp =
405 				sbe.ProtectionTokenParameters
406 				as X509SecurityTokenParameters;
407 			Assert.IsNotNull (sp, "#2");
408 			Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
409 					 sp.ReferenceStyle, "#3");
410 			Assert.AreEqual (SecurityTokenInclusionMode.Never,
411 					 sp.InclusionMode, "#4");
412 
413 			UserNameSecurityTokenParameters up =
414 				sbe.EndpointSupportingTokenParameters.SignedEncrypted [0]
415 				as UserNameSecurityTokenParameters;
416 			Assert.AreEqual (SecurityTokenReferenceStyle.Internal,
417 					 up.ReferenceStyle, "#5");
418 			Assert.AreEqual (SecurityTokenInclusionMode.AlwaysToRecipient,
419 					 up.InclusionMode, "#6");
420 		}
421 
422 		[Test]
423 		[Category ("NotWorking")]
MessageSecurityIssuedToken()424 		public void MessageSecurityIssuedToken ()
425 		{
426 			WSHttpBinding binding = new WSHttpBinding ();
427 			binding.Security.Message.EstablishSecurityContext = false;
428 			binding.Security.Message.ClientCredentialType =
429 				MessageCredentialType.IssuedToken;
430 			SymmetricSecurityBindingElement sbe =
431 				binding.CreateBindingElements ().Find<SymmetricSecurityBindingElement> ();
432 			Assert.IsNotNull (sbe, "#1");
433 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.Signed.Count, "#1-1");
434 			Assert.AreEqual (1, sbe.EndpointSupportingTokenParameters.Endorsing.Count, "#1-2");
435 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEndorsing.Count, "#1-3");
436 			Assert.AreEqual (0, sbe.EndpointSupportingTokenParameters.SignedEncrypted.Count, "#1-4");
437 			IssuedSecurityTokenParameters p =
438 				sbe.EndpointSupportingTokenParameters.Endorsing [0]
439 				as IssuedSecurityTokenParameters;
440 			Assert.IsNotNull (p, "#2");
441 			Assert.IsNotNull (p.ClaimTypeRequirements, "#2-1");
442 			Assert.AreEqual (1, p.ClaimTypeRequirements.Count, "#2-2");
443 			ClaimTypeRequirement r = p.ClaimTypeRequirements [0];
444 			Assert.AreEqual (ClaimTypes.PPID, r.ClaimType, "#3-1");
445 			Assert.IsFalse (r.IsOptional, "#3-2");
446 		}
447 
448 		[Test]
449 		[ExpectedException (typeof (InvalidOperationException))]
450 		[Category ("NotWorking")]
BuildListenerWithoutServiceCertificate()451 		public void BuildListenerWithoutServiceCertificate ()
452 		{
453 			ServiceHost host = new ServiceHost (typeof (Foo));
454 			WSHttpBinding binding = new WSHttpBinding ();
455 			binding.Security.Message.ClientCredentialType =
456 				MessageCredentialType.IssuedToken;
457 			host.AddServiceEndpoint (typeof (Foo).FullName, binding, "http://localhost:8080");
458 			host.Open ();
459 		}
460 
461 		[ServiceContract]
462 		class Foo
463 		{
464 			[OperationContract]
SayWhat()465 			public void SayWhat () { }
466 		}
467 
468 		class MyWSBinding : WSHttpBinding
469 		{
MyWSBinding(SecurityMode mode)470 			public MyWSBinding (SecurityMode mode)
471 				: base (mode)
472 			{
473 			}
474 
CreateMessageSecurityEx()475 			public SecurityBindingElement CreateMessageSecurityEx ()
476 			{
477 				return CreateMessageSecurity ();
478 			}
479 		}
480 	}
481 }
482 #endif
483