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