2 // MessageSecurityVersionTest.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.
30 using System.Collections.ObjectModel;
31 using System.ServiceModel;
32 using System.ServiceModel.Channels;
33 using System.ServiceModel.Description;
34 using NUnit.Framework;
36 namespace MonoTests.System.ServiceModel
39 public class MessageSecurityVersionTest
42 public void Default ()
45 MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11,
46 MessageSecurityVersion.Default,
47 "dude, stop using crappy lengthy name");
51 public void SecurityTokenVersion ()
53 ReadOnlyCollection<string> specs =
54 MessageSecurityVersion.Default.SecurityTokenVersion.GetSecuritySpecifications ();
55 Assert.AreEqual (3, specs.Count, "#1");
56 // Not sure why MS limits the results to them. This
57 // result rather means that it is not worthy of
59 string [] expected = new string [] {
60 "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
61 "http://schemas.xmlsoap.org/ws/2005/02/trust",
62 "http://schemas.xmlsoap.org/ws/2005/02/sc"
64 foreach (string spec in specs)
65 if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
66 Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#2");
68 specs = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10.SecurityTokenVersion.GetSecuritySpecifications ();
69 Assert.AreEqual (4, specs.Count, "#3");
70 // Not sure why MS limits the results to them. This
71 // result rather means that it is not worthy of testing.
72 expected = new string [] {
73 "http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd",
74 "http://schemas.xmlsoap.org/ws/2005/02/trust",
75 "http://schemas.xmlsoap.org/ws/2005/02/sc",
76 "http://ws-i.org/profiles/basic-security/core/1.0",
78 foreach (string spec in specs)
79 if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
80 Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#4");
82 specs = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10.SecurityTokenVersion.GetSecuritySpecifications ();
83 Assert.AreEqual (4, specs.Count, "#5");
84 // Not sure why MS limits the results to them. This
85 // result rather means that it is not worthy of testing.
86 expected = new string [] {
87 "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd",
88 "http://schemas.xmlsoap.org/ws/2005/02/trust",
89 "http://schemas.xmlsoap.org/ws/2005/02/sc",
90 "http://ws-i.org/profiles/basic-security/core/1.0",
92 foreach (string spec in specs)
93 if (!Array.Exists<string> (expected, delegate (string s) { return s == spec; }))
94 Assert.Fail (String.Format ("Unexpected spec '{0}'", spec), "#6");