Merge pull request #3913 from omwok/master
[mono.git] / mcs / class / System.ServiceModel / Test / MetadataTests / ImportTests.cs
1 //
2 // Testcases.cs
3 //
4 // Author:
5 //       Martin Baulig <martin.baulig@xamarin.com>
6 //
7 // Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
8 //
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:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
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
25 // THE SOFTWARE.
26
27 using System;
28 using System.Net;
29 using System.Xml;
30 using System.Text;
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
38 using WS = System.Web.Services.Description;
39
40 namespace MonoTests.System.ServiceModel.MetadataTests {
41
42         /*
43          * This class is abstract to allow it to be run multiple times with
44          * different TestContexts.
45          */
46         [Category ("MetadataTests")]
47         public abstract class ImportTests {
48
49                 public abstract TestContext Context {
50                         get;
51                 }
52
53                 protected MetadataSet GetMetadata (string name, out TestLabel label)
54                 {
55                         label = new TestLabel (name);
56                         return Context.GetMetadata (name);
57                 }
58
59                 protected MetadataSet GetMetadataAndConfig (
60                         string name, out XmlDocument config, out TestLabel label)
61                 {
62                         var metadata = GetMetadata (name, out label);
63                         config = Context.GetConfiguration (name);
64                         return metadata;
65                 }
66
67                 [Test]
68                 public virtual void BasicHttp ()
69                 {
70                         TestLabel label;
71                         var doc = GetMetadata ("BasicHttp", out label);
72
73                         BindingTestAssertions.BasicHttpBinding (
74                                 Context, doc, BasicHttpSecurityMode.None, label);
75                 }
76                 
77                 [Test]
78                 public virtual void BasicHttp_TransportSecurity ()
79                 {
80                         TestLabel label;
81                         var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
82
83                         BindingTestAssertions.BasicHttpBinding (
84                                 Context, doc, BasicHttpSecurityMode.Transport, label);
85                 }
86                 
87                 [Test]
88                 [Category ("NotWorking")]
89                 public virtual void BasicHttp_MessageSecurity ()
90                 {
91                         TestLabel label;
92                         var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
93
94                         BindingTestAssertions.BasicHttpBinding (
95                                 Context, doc, BasicHttpSecurityMode.Message, label);
96                 }
97                 
98                 [Test]
99                 [Category ("NotWorking")]
100                 public virtual void BasicHttp_TransportWithMessageCredential ()
101                 {
102                         TestLabel label;
103                         var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
104
105                         BindingTestAssertions.BasicHttpBinding (
106                                 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
107                 }
108                 
109                 [Test]
110                 public virtual void BasicHttp_Mtom ()
111                 {
112                         TestLabel label;
113                         var doc = GetMetadata ("BasicHttp_Mtom", out label);
114
115                         BindingTestAssertions.BasicHttpBinding (
116                                 Context, doc, WSMessageEncoding.Mtom, label);
117                 }
118
119                 [Test]
120                 public virtual void BasicHttp_NtlmAuth ()
121                 {
122                         TestLabel label;
123                         var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
124
125                         BindingTestAssertions.BasicHttpBinding (
126                                 Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
127                                 WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
128                                 AuthenticationSchemes.Ntlm, label);
129                 }
130
131                 [Test]
132                 public virtual void BasicHttps ()
133                 {
134                         TestLabel label;
135                         var doc = GetMetadata ("BasicHttps", out label);
136
137                         BindingTestAssertions.BasicHttpsBinding (
138                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
139                                 HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
140                                 label);
141                 }
142                 
143                 [Test]
144                 public virtual void BasicHttps_NtlmAuth ()
145                 {
146                         TestLabel label;
147                         var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
148
149                         BindingTestAssertions.BasicHttpsBinding (
150                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
151                                 HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
152                                 label);
153                 }
154                 
155                 [Test]
156                 [Category ("NotWorking")]
157                 public virtual void BasicHttps_Certificate ()
158                 {
159                         TestLabel label;
160                         var doc = GetMetadata ("BasicHttps_Certificate", out label);
161
162                         BindingTestAssertions.BasicHttpsBinding (
163                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
164                                 HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
165                                 label);
166                 }
167                 
168                 [Test]
169                 [Category ("NotWorking")]
170                 public virtual void BasicHttps_TransportWithMessageCredential ()
171                 {
172                         TestLabel label;
173                         var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
174
175                         BindingTestAssertions.BasicHttpsBinding (
176                                 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
177                                 WSMessageEncoding.Text, HttpClientCredentialType.None,
178                                 AuthenticationSchemes.Anonymous, label);
179                 }
180                 
181                 [Test]
182                 public virtual void NetTcp ()
183                 {
184                         TestLabel label;
185                         var doc = GetMetadata ("NetTcp", out label);
186
187                         BindingTestAssertions.NetTcpBinding (
188                                 Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
189                 }
190
191                 [Test]
192                 public virtual void NetTcp_TransferMode ()
193                 {
194                         TestLabel label;
195                         var doc = GetMetadata ("NetTcp_TransferMode", out label);
196
197                         BindingTestAssertions.NetTcpBinding (
198                                 Context, doc, SecurityMode.None, false,
199                                 TransferMode.Streamed, label);
200                 }
201
202                 [Test]
203                 public virtual void NetTcp_TransportSecurity ()
204                 {
205                         TestLabel label;
206                         var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
207
208                         BindingTestAssertions.NetTcpBinding (
209                                 Context, doc, SecurityMode.Transport, false,
210                                 TransferMode.Buffered, label);
211                 }
212                 
213                 [Test]
214                 [Category ("NotWorking")]
215                 public virtual void NetTcp_MessageSecurity ()
216                 {
217                         TestLabel label;
218                         var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
219
220                         BindingTestAssertions.NetTcpBinding (
221                                 Context, doc, SecurityMode.Message, false,
222                                 TransferMode.Buffered, label);
223                 }
224                 
225                 [Test]
226                 [Category ("NotWorking")]
227                 public virtual void NetTcp_TransportWithMessageCredential ()
228                 {
229                         TestLabel label;
230                         var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
231
232                         BindingTestAssertions.NetTcpBinding (
233                                 Context, doc, SecurityMode.TransportWithMessageCredential, false,
234                                 TransferMode.Buffered, label);
235                 }
236
237                 [Test]
238                 public virtual void NetTcp_Binding ()
239                 {
240                         var label = new TestLabel ("NetTcp_Binding");
241
242                         label.EnterScope ("None");
243                         BindingTestAssertions.CheckNetTcpBinding (
244                                 new NetTcpBinding (SecurityMode.None), SecurityMode.None,
245                                 false, TransferMode.Buffered, label);
246                         label.LeaveScope ();
247
248                         label.EnterScope ("Transport");
249                         BindingTestAssertions.CheckNetTcpBinding (
250                                 new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
251                                 false, TransferMode.Buffered, label);
252                         label.LeaveScope ();
253                 }
254
255                 [Test]
256                 [Category ("NotWorking")]
257                 public virtual void NetTcp_Binding2 ()
258                 {
259                         var label = new TestLabel ("NetTcp_Binding2");
260
261                         label.EnterScope ("TransportWithMessageCredential");
262                         BindingTestAssertions.CheckNetTcpBinding (
263                                 new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
264                                 SecurityMode.TransportWithMessageCredential, false,
265                                 TransferMode.Buffered, label);
266                         label.LeaveScope ();
267                 }
268                 
269                 [Test]
270                 [Category ("NotWorking")]
271                 public virtual void NetTcp_ReliableSession ()
272                 {
273                         TestLabel label;
274                         var doc = GetMetadata ("NetTcp_ReliableSession", out label);
275
276                         BindingTestAssertions.NetTcpBinding (
277                                 Context, doc, SecurityMode.None, true,
278                                 TransferMode.Buffered, label);
279                 }
280
281                 [Test]
282                 public virtual void BasicHttp_Operation ()
283                 {
284                         TestLabel label;
285                         var doc = GetMetadata ("BasicHttp_Operation", out label);
286
287                         BindingTestAssertions.TestOperation (doc, false, label);
288                 }
289
290                 [Test]
291                 public virtual void NetTcp_Operation ()
292                 {
293                         TestLabel label;
294                         var doc = GetMetadata ("NetTcp_Operation", out label);
295
296                         BindingTestAssertions.TestOperation (doc, true, label);
297                 }
298
299                 [Test]
300                 public virtual void BasicHttp_Config ()
301                 {
302                         TestLabel label;
303                         XmlDocument config;
304                         var metadata = GetMetadataAndConfig (
305                                 "BasicHttp_Config", out config, out label);
306
307                         BindingTestAssertions.AssertConfig (metadata, config, label);
308                 }
309
310                 [Test]
311                 public virtual void BasicHttp_Config2 ()
312                 {
313                         TestLabel label;
314                         XmlDocument config;
315                         var metadata = GetMetadataAndConfig (
316                                 "BasicHttp_Config2", out config, out label);
317                         
318                         BindingTestAssertions.AssertConfig (metadata, config, label);
319                 }
320         }
321
322 }
323