5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 using System.Collections.Generic;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34 using System.ServiceModel.Description;
35 using NUnit.Framework;
36 using NUnit.Framework.Constraints;
38 using WS = System.Web.Services.Description;
40 namespace MonoTests.System.ServiceModel.MetadataTests {
43 * This class is abstract to allow it to be run multiple times with
44 * different TestContexts.
46 [Category ("MetadataTests")]
47 public abstract class ImportTests {
49 public abstract TestContext Context {
53 protected MetadataSet GetMetadata (string name, out TestLabel label)
55 label = new TestLabel (name);
56 return Context.GetMetadata (name);
59 protected MetadataSet GetMetadataAndConfig (
60 string name, out XmlDocument config, out TestLabel label)
62 var metadata = GetMetadata (name, out label);
63 config = Context.GetConfiguration (name);
68 public virtual void BasicHttp ()
71 var doc = GetMetadata ("BasicHttp", out label);
73 BindingTestAssertions.BasicHttpBinding (
74 Context, doc, BasicHttpSecurityMode.None, label);
78 public virtual void BasicHttp_TransportSecurity ()
81 var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
83 BindingTestAssertions.BasicHttpBinding (
84 Context, doc, BasicHttpSecurityMode.Transport, label);
88 [Category ("NotWorking")]
89 public virtual void BasicHttp_MessageSecurity ()
92 var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
94 BindingTestAssertions.BasicHttpBinding (
95 Context, doc, BasicHttpSecurityMode.Message, label);
99 [Category ("NotWorking")]
100 public virtual void BasicHttp_TransportWithMessageCredential ()
103 var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
105 BindingTestAssertions.BasicHttpBinding (
106 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
110 public virtual void BasicHttp_Mtom ()
113 var doc = GetMetadata ("BasicHttp_Mtom", out label);
115 BindingTestAssertions.BasicHttpBinding (
116 Context, doc, WSMessageEncoding.Mtom, label);
120 public virtual void BasicHttp_NtlmAuth ()
123 var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
125 BindingTestAssertions.BasicHttpBinding (
126 Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
127 WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
128 AuthenticationSchemes.Ntlm, label);
132 public virtual void BasicHttps ()
135 var doc = GetMetadata ("BasicHttps", out label);
137 BindingTestAssertions.BasicHttpsBinding (
138 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
139 HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
144 public virtual void BasicHttps_NtlmAuth ()
147 var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
149 BindingTestAssertions.BasicHttpsBinding (
150 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
151 HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
156 [Category ("NotWorking")]
157 public virtual void BasicHttps_Certificate ()
160 var doc = GetMetadata ("BasicHttps_Certificate", out label);
162 BindingTestAssertions.BasicHttpsBinding (
163 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
164 HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
169 [Category ("NotWorking")]
170 public virtual void BasicHttps_TransportWithMessageCredential ()
173 var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
175 BindingTestAssertions.BasicHttpsBinding (
176 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
177 WSMessageEncoding.Text, HttpClientCredentialType.None,
178 AuthenticationSchemes.Anonymous, label);
182 public virtual void NetTcp ()
185 var doc = GetMetadata ("NetTcp", out label);
187 BindingTestAssertions.NetTcpBinding (
188 Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
192 public virtual void NetTcp_TransferMode ()
195 var doc = GetMetadata ("NetTcp_TransferMode", out label);
197 BindingTestAssertions.NetTcpBinding (
198 Context, doc, SecurityMode.None, false,
199 TransferMode.Streamed, label);
203 public virtual void NetTcp_TransportSecurity ()
206 var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
208 BindingTestAssertions.NetTcpBinding (
209 Context, doc, SecurityMode.Transport, false,
210 TransferMode.Buffered, label);
214 [Category ("NotWorking")]
215 public virtual void NetTcp_MessageSecurity ()
218 var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
220 BindingTestAssertions.NetTcpBinding (
221 Context, doc, SecurityMode.Message, false,
222 TransferMode.Buffered, label);
226 [Category ("NotWorking")]
227 public virtual void NetTcp_TransportWithMessageCredential ()
230 var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
232 BindingTestAssertions.NetTcpBinding (
233 Context, doc, SecurityMode.TransportWithMessageCredential, false,
234 TransferMode.Buffered, label);
238 public virtual void NetTcp_Binding ()
240 var label = new TestLabel ("NetTcp_Binding");
242 label.EnterScope ("None");
243 BindingTestAssertions.CheckNetTcpBinding (
244 new NetTcpBinding (SecurityMode.None), SecurityMode.None,
245 false, TransferMode.Buffered, label);
248 label.EnterScope ("Transport");
249 BindingTestAssertions.CheckNetTcpBinding (
250 new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
251 false, TransferMode.Buffered, label);
256 [Category ("NotWorking")]
257 public virtual void NetTcp_Binding2 ()
259 var label = new TestLabel ("NetTcp_Binding2");
261 label.EnterScope ("TransportWithMessageCredential");
262 BindingTestAssertions.CheckNetTcpBinding (
263 new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
264 SecurityMode.TransportWithMessageCredential, false,
265 TransferMode.Buffered, label);
270 [Category ("NotWorking")]
271 public virtual void NetTcp_ReliableSession ()
274 var doc = GetMetadata ("NetTcp_ReliableSession", out label);
276 BindingTestAssertions.NetTcpBinding (
277 Context, doc, SecurityMode.None, true,
278 TransferMode.Buffered, label);
282 public virtual void BasicHttp_Operation ()
285 var doc = GetMetadata ("BasicHttp_Operation", out label);
287 BindingTestAssertions.TestOperation (doc, false, label);
291 public virtual void NetTcp_Operation ()
294 var doc = GetMetadata ("NetTcp_Operation", out label);
296 BindingTestAssertions.TestOperation (doc, true, label);
300 public virtual void BasicHttp_Config ()
304 var metadata = GetMetadataAndConfig (
305 "BasicHttp_Config", out config, out label);
307 BindingTestAssertions.AssertConfig (metadata, config, label);
311 public virtual void BasicHttp_Config2 ()
315 var metadata = GetMetadataAndConfig (
316 "BasicHttp_Config2", out config, out label);
318 BindingTestAssertions.AssertConfig (metadata, config, label);