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;
37 using NUnit.Framework.SyntaxHelpers;
39 using WS = System.Web.Services.Description;
41 namespace MonoTests.System.ServiceModel.MetadataTests {
44 * This class is abstract to allow it to be run multiple times with
45 * different TestContexts.
47 [Category ("MetadataTests")]
48 public abstract class ImportTests {
50 public abstract TestContext Context {
54 protected MetadataSet GetMetadata (string name, out TestLabel label)
56 label = new TestLabel (name);
57 return Context.GetMetadata (name);
60 protected MetadataSet GetMetadataAndConfig (
61 string name, out XmlDocument config, out TestLabel label)
63 var metadata = GetMetadata (name, out label);
64 config = Context.GetConfiguration (name);
69 public virtual void BasicHttp ()
72 var doc = GetMetadata ("BasicHttp", out label);
74 BindingTestAssertions.BasicHttpBinding (
75 Context, doc, BasicHttpSecurityMode.None, label);
79 public virtual void BasicHttp_TransportSecurity ()
82 var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
84 BindingTestAssertions.BasicHttpBinding (
85 Context, doc, BasicHttpSecurityMode.Transport, label);
89 [Category ("NotWorking")]
90 public virtual void BasicHttp_MessageSecurity ()
93 var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
95 BindingTestAssertions.BasicHttpBinding (
96 Context, doc, BasicHttpSecurityMode.Message, label);
100 [Category ("NotWorking")]
101 public virtual void BasicHttp_TransportWithMessageCredential ()
104 var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
106 BindingTestAssertions.BasicHttpBinding (
107 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
111 public virtual void BasicHttp_Mtom ()
114 var doc = GetMetadata ("BasicHttp_Mtom", out label);
116 BindingTestAssertions.BasicHttpBinding (
117 Context, doc, WSMessageEncoding.Mtom, label);
121 public virtual void BasicHttp_NtlmAuth ()
124 var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
126 BindingTestAssertions.BasicHttpBinding (
127 Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
128 WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
129 AuthenticationSchemes.Ntlm, label);
133 public virtual void BasicHttps ()
136 var doc = GetMetadata ("BasicHttps", out label);
138 BindingTestAssertions.BasicHttpsBinding (
139 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
140 HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
145 public virtual void BasicHttps_NtlmAuth ()
148 var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
150 BindingTestAssertions.BasicHttpsBinding (
151 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
152 HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
157 [Category ("NotWorking")]
158 public virtual void BasicHttps_Certificate ()
161 var doc = GetMetadata ("BasicHttps_Certificate", out label);
163 BindingTestAssertions.BasicHttpsBinding (
164 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
165 HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
170 [Category ("NotWorking")]
171 public virtual void BasicHttps_TransportWithMessageCredential ()
174 var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
176 BindingTestAssertions.BasicHttpsBinding (
177 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
178 WSMessageEncoding.Text, HttpClientCredentialType.None,
179 AuthenticationSchemes.Anonymous, label);
183 public virtual void NetTcp ()
186 var doc = GetMetadata ("NetTcp", out label);
188 BindingTestAssertions.NetTcpBinding (
189 Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
193 public virtual void NetTcp_TransferMode ()
196 var doc = GetMetadata ("NetTcp_TransferMode", out label);
198 BindingTestAssertions.NetTcpBinding (
199 Context, doc, SecurityMode.None, false,
200 TransferMode.Streamed, label);
204 public virtual void NetTcp_TransportSecurity ()
207 var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
209 BindingTestAssertions.NetTcpBinding (
210 Context, doc, SecurityMode.Transport, false,
211 TransferMode.Buffered, label);
215 [Category ("NotWorking")]
216 public virtual void NetTcp_MessageSecurity ()
219 var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
221 BindingTestAssertions.NetTcpBinding (
222 Context, doc, SecurityMode.Message, false,
223 TransferMode.Buffered, label);
227 [Category ("NotWorking")]
228 public virtual void NetTcp_TransportWithMessageCredential ()
231 var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
233 BindingTestAssertions.NetTcpBinding (
234 Context, doc, SecurityMode.TransportWithMessageCredential, false,
235 TransferMode.Buffered, label);
239 public virtual void NetTcp_Binding ()
241 var label = new TestLabel ("NetTcp_Binding");
243 label.EnterScope ("None");
244 BindingTestAssertions.CheckNetTcpBinding (
245 new NetTcpBinding (SecurityMode.None), SecurityMode.None,
246 false, TransferMode.Buffered, label);
249 label.EnterScope ("Transport");
250 BindingTestAssertions.CheckNetTcpBinding (
251 new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
252 false, TransferMode.Buffered, label);
257 [Category ("NotWorking")]
258 public virtual void NetTcp_Binding2 ()
260 var label = new TestLabel ("NetTcp_Binding2");
262 label.EnterScope ("TransportWithMessageCredential");
263 BindingTestAssertions.CheckNetTcpBinding (
264 new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
265 SecurityMode.TransportWithMessageCredential, false,
266 TransferMode.Buffered, label);
271 [Category ("NotWorking")]
272 public virtual void NetTcp_ReliableSession ()
275 var doc = GetMetadata ("NetTcp_ReliableSession", out label);
277 BindingTestAssertions.NetTcpBinding (
278 Context, doc, SecurityMode.None, true,
279 TransferMode.Buffered, label);
283 public virtual void BasicHttp_Operation ()
286 var doc = GetMetadata ("BasicHttp_Operation", out label);
288 BindingTestAssertions.TestOperation (doc, false, label);
292 public virtual void NetTcp_Operation ()
295 var doc = GetMetadata ("NetTcp_Operation", out label);
297 BindingTestAssertions.TestOperation (doc, true, label);
301 public virtual void BasicHttp_Config ()
305 var metadata = GetMetadataAndConfig (
306 "BasicHttp_Config", out config, out label);
308 BindingTestAssertions.AssertConfig (metadata, config, label);
312 public virtual void BasicHttp_Config2 ()
316 var metadata = GetMetadataAndConfig (
317 "BasicHttp_Config2", out config, out label);
319 BindingTestAssertions.AssertConfig (metadata, config, label);