Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[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                 [Test]
61                 public virtual void BasicHttp ()
62                 {
63                         TestLabel label;
64                         var doc = GetMetadata ("BasicHttp", out label);
65
66                         BindingTestAssertions.BasicHttpBinding (
67                                 Context, doc, BasicHttpSecurityMode.None, label);
68                 }
69                 
70                 [Test]
71                 public virtual void BasicHttp_TransportSecurity ()
72                 {
73                         TestLabel label;
74                         var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
75
76                         BindingTestAssertions.BasicHttpBinding (
77                                 Context, doc, BasicHttpSecurityMode.Transport, label);
78                 }
79                 
80                 [Test]
81                 [Category ("NotWorking")]
82                 public virtual void BasicHttp_MessageSecurity ()
83                 {
84                         TestLabel label;
85                         var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
86
87                         BindingTestAssertions.BasicHttpBinding (
88                                 Context, doc, BasicHttpSecurityMode.Message, label);
89                 }
90                 
91                 [Test]
92                 [Category ("NotWorking")]
93                 public virtual void BasicHttp_TransportWithMessageCredential ()
94                 {
95                         TestLabel label;
96                         var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
97
98                         BindingTestAssertions.BasicHttpBinding (
99                                 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
100                 }
101                 
102                 [Test]
103                 public virtual void BasicHttp_Mtom ()
104                 {
105                         TestLabel label;
106                         var doc = GetMetadata ("BasicHttp_Mtom", out label);
107
108                         BindingTestAssertions.BasicHttpBinding (
109                                 Context, doc, WSMessageEncoding.Mtom, label);
110                 }
111
112                 [Test]
113                 public virtual void BasicHttp_NtlmAuth ()
114                 {
115                         TestLabel label;
116                         var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
117
118                         BindingTestAssertions.BasicHttpBinding (
119                                 Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
120                                 WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
121                                 AuthenticationSchemes.Ntlm, label);
122                 }
123
124 #if NET_4_5
125                 [Test]
126                 public virtual void BasicHttps ()
127                 {
128                         TestLabel label;
129                         var doc = GetMetadata ("BasicHttps", out label);
130
131                         BindingTestAssertions.BasicHttpsBinding (
132                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
133                                 HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
134                                 label);
135                 }
136                 
137                 [Test]
138                 public virtual void BasicHttps_NtlmAuth ()
139                 {
140                         TestLabel label;
141                         var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
142
143                         BindingTestAssertions.BasicHttpsBinding (
144                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
145                                 HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
146                                 label);
147                 }
148                 
149                 [Test]
150                 [Category ("NotWorking")]
151                 public virtual void BasicHttps_Certificate ()
152                 {
153                         TestLabel label;
154                         var doc = GetMetadata ("BasicHttps_Certificate", out label);
155
156                         BindingTestAssertions.BasicHttpsBinding (
157                                 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
158                                 HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
159                                 label);
160                 }
161                 
162                 [Test]
163                 [Category ("NotWorking")]
164                 public virtual void BasicHttps_TransportWithMessageCredential ()
165                 {
166                         TestLabel label;
167                         var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
168
169                         BindingTestAssertions.BasicHttpsBinding (
170                                 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
171                                 WSMessageEncoding.Text, HttpClientCredentialType.None,
172                                 AuthenticationSchemes.Anonymous, label);
173                 }
174 #endif
175                 
176                 [Test]
177                 public virtual void NetTcp ()
178                 {
179                         TestLabel label;
180                         var doc = GetMetadata ("NetTcp", out label);
181
182                         BindingTestAssertions.NetTcpBinding (
183                                 Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
184                 }
185
186                 [Test]
187                 public virtual void NetTcp_TransferMode ()
188                 {
189                         TestLabel label;
190                         var doc = GetMetadata ("NetTcp_TransferMode", out label);
191
192                         BindingTestAssertions.NetTcpBinding (
193                                 Context, doc, SecurityMode.None, false,
194                                 TransferMode.Streamed, label);
195                 }
196
197                 [Test]
198                 public virtual void NetTcp_TransportSecurity ()
199                 {
200                         TestLabel label;
201                         var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
202
203                         BindingTestAssertions.NetTcpBinding (
204                                 Context, doc, SecurityMode.Transport, false,
205                                 TransferMode.Buffered, label);
206                 }
207                 
208                 [Test]
209                 [Category ("NotWorking")]
210                 public virtual void NetTcp_MessageSecurity ()
211                 {
212                         TestLabel label;
213                         var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
214
215                         BindingTestAssertions.NetTcpBinding (
216                                 Context, doc, SecurityMode.Message, false,
217                                 TransferMode.Buffered, label);
218                 }
219                 
220                 [Test]
221                 [Category ("NotWorking")]
222                 public virtual void NetTcp_TransportWithMessageCredential ()
223                 {
224                         TestLabel label;
225                         var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
226
227                         BindingTestAssertions.NetTcpBinding (
228                                 Context, doc, SecurityMode.TransportWithMessageCredential, false,
229                                 TransferMode.Buffered, label);
230                 }
231
232                 [Test]
233                 public virtual void NetTcp_Binding ()
234                 {
235                         var label = new TestLabel ("NetTcp_Binding");
236
237                         label.EnterScope ("None");
238                         BindingTestAssertions.CheckNetTcpBinding (
239                                 new NetTcpBinding (SecurityMode.None), SecurityMode.None,
240                                 false, TransferMode.Buffered, label);
241                         label.LeaveScope ();
242
243                         label.EnterScope ("Transport");
244                         BindingTestAssertions.CheckNetTcpBinding (
245                                 new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
246                                 false, TransferMode.Buffered, label);
247                         label.LeaveScope ();
248                 }
249
250                 [Test]
251                 [Category ("NotWorking")]
252                 public virtual void NetTcp_Binding2 ()
253                 {
254                         var label = new TestLabel ("NetTcp_Binding2");
255
256                         label.EnterScope ("TransportWithMessageCredential");
257                         BindingTestAssertions.CheckNetTcpBinding (
258                                 new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
259                                 SecurityMode.TransportWithMessageCredential, false,
260                                 TransferMode.Buffered, label);
261                         label.LeaveScope ();
262                 }
263                 
264                 [Test]
265                 [Category ("NotWorking")]
266                 public virtual void NetTcp_ReliableSession ()
267                 {
268                         TestLabel label;
269                         var doc = GetMetadata ("NetTcp_ReliableSession", out label);
270
271                         BindingTestAssertions.NetTcpBinding (
272                                 Context, doc, SecurityMode.None, true,
273                                 TransferMode.Buffered, label);
274                 }
275
276                 [Test]
277                 public virtual void BasicHttp_Operation ()
278                 {
279                         TestLabel label;
280                         var doc = GetMetadata ("BasicHttp_Operation", out label);
281
282                         BindingTestAssertions.TestOperation (doc, false, label);
283                 }
284
285                 [Test]
286                 public virtual void NetTcp_Operation ()
287                 {
288                         TestLabel label;
289                         var doc = GetMetadata ("NetTcp_Operation", out label);
290
291                         BindingTestAssertions.TestOperation (doc, true, label);
292                 }
293         }
294
295 }
296