ImportTests.cs 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. //
  2. // Testcases.cs
  3. //
  4. // Author:
  5. // Martin Baulig <[email protected]>
  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. using System;
  27. using System.Net;
  28. using System.Xml;
  29. using System.Text;
  30. using System.Collections.Generic;
  31. using System.ServiceModel;
  32. using System.ServiceModel.Channels;
  33. using System.ServiceModel.Description;
  34. using NUnit.Framework;
  35. using NUnit.Framework.Constraints;
  36. using NUnit.Framework.SyntaxHelpers;
  37. using WS = System.Web.Services.Description;
  38. namespace MonoTests.System.ServiceModel.MetadataTests {
  39. /*
  40. * This class is abstract to allow it to be run multiple times with
  41. * different TestContexts.
  42. */
  43. [Category ("MetadataTests")]
  44. public abstract class ImportTests {
  45. public abstract TestContext Context {
  46. get;
  47. }
  48. protected MetadataSet GetMetadata (string name, out TestLabel label)
  49. {
  50. label = new TestLabel (name);
  51. return Context.GetMetadata (name);
  52. }
  53. protected MetadataSet GetMetadataAndConfig (
  54. string name, out XmlDocument config, out TestLabel label)
  55. {
  56. var metadata = GetMetadata (name, out label);
  57. config = Context.GetConfiguration (name);
  58. return metadata;
  59. }
  60. [Test]
  61. public virtual void BasicHttp ()
  62. {
  63. TestLabel label;
  64. var doc = GetMetadata ("BasicHttp", out label);
  65. BindingTestAssertions.BasicHttpBinding (
  66. Context, doc, BasicHttpSecurityMode.None, label);
  67. }
  68. [Test]
  69. public virtual void BasicHttp_TransportSecurity ()
  70. {
  71. TestLabel label;
  72. var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
  73. BindingTestAssertions.BasicHttpBinding (
  74. Context, doc, BasicHttpSecurityMode.Transport, label);
  75. }
  76. [Test]
  77. [Category ("NotWorking")]
  78. public virtual void BasicHttp_MessageSecurity ()
  79. {
  80. TestLabel label;
  81. var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
  82. BindingTestAssertions.BasicHttpBinding (
  83. Context, doc, BasicHttpSecurityMode.Message, label);
  84. }
  85. [Test]
  86. [Category ("NotWorking")]
  87. public virtual void BasicHttp_TransportWithMessageCredential ()
  88. {
  89. TestLabel label;
  90. var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
  91. BindingTestAssertions.BasicHttpBinding (
  92. Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
  93. }
  94. [Test]
  95. public virtual void BasicHttp_Mtom ()
  96. {
  97. TestLabel label;
  98. var doc = GetMetadata ("BasicHttp_Mtom", out label);
  99. BindingTestAssertions.BasicHttpBinding (
  100. Context, doc, WSMessageEncoding.Mtom, label);
  101. }
  102. [Test]
  103. public virtual void BasicHttp_NtlmAuth ()
  104. {
  105. TestLabel label;
  106. var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
  107. BindingTestAssertions.BasicHttpBinding (
  108. Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
  109. WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
  110. AuthenticationSchemes.Ntlm, label);
  111. }
  112. #if NET_4_5
  113. [Test]
  114. public virtual void BasicHttps ()
  115. {
  116. TestLabel label;
  117. var doc = GetMetadata ("BasicHttps", out label);
  118. BindingTestAssertions.BasicHttpsBinding (
  119. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  120. HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
  121. label);
  122. }
  123. [Test]
  124. public virtual void BasicHttps_NtlmAuth ()
  125. {
  126. TestLabel label;
  127. var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
  128. BindingTestAssertions.BasicHttpsBinding (
  129. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  130. HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
  131. label);
  132. }
  133. [Test]
  134. [Category ("NotWorking")]
  135. public virtual void BasicHttps_Certificate ()
  136. {
  137. TestLabel label;
  138. var doc = GetMetadata ("BasicHttps_Certificate", out label);
  139. BindingTestAssertions.BasicHttpsBinding (
  140. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  141. HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
  142. label);
  143. }
  144. [Test]
  145. [Category ("NotWorking")]
  146. public virtual void BasicHttps_TransportWithMessageCredential ()
  147. {
  148. TestLabel label;
  149. var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
  150. BindingTestAssertions.BasicHttpsBinding (
  151. Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
  152. WSMessageEncoding.Text, HttpClientCredentialType.None,
  153. AuthenticationSchemes.Anonymous, label);
  154. }
  155. #endif
  156. [Test]
  157. public virtual void NetTcp ()
  158. {
  159. TestLabel label;
  160. var doc = GetMetadata ("NetTcp", out label);
  161. BindingTestAssertions.NetTcpBinding (
  162. Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
  163. }
  164. [Test]
  165. public virtual void NetTcp_TransferMode ()
  166. {
  167. TestLabel label;
  168. var doc = GetMetadata ("NetTcp_TransferMode", out label);
  169. BindingTestAssertions.NetTcpBinding (
  170. Context, doc, SecurityMode.None, false,
  171. TransferMode.Streamed, label);
  172. }
  173. [Test]
  174. public virtual void NetTcp_TransportSecurity ()
  175. {
  176. TestLabel label;
  177. var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
  178. BindingTestAssertions.NetTcpBinding (
  179. Context, doc, SecurityMode.Transport, false,
  180. TransferMode.Buffered, label);
  181. }
  182. [Test]
  183. [Category ("NotWorking")]
  184. public virtual void NetTcp_MessageSecurity ()
  185. {
  186. TestLabel label;
  187. var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
  188. BindingTestAssertions.NetTcpBinding (
  189. Context, doc, SecurityMode.Message, false,
  190. TransferMode.Buffered, label);
  191. }
  192. [Test]
  193. [Category ("NotWorking")]
  194. public virtual void NetTcp_TransportWithMessageCredential ()
  195. {
  196. TestLabel label;
  197. var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
  198. BindingTestAssertions.NetTcpBinding (
  199. Context, doc, SecurityMode.TransportWithMessageCredential, false,
  200. TransferMode.Buffered, label);
  201. }
  202. [Test]
  203. public virtual void NetTcp_Binding ()
  204. {
  205. var label = new TestLabel ("NetTcp_Binding");
  206. label.EnterScope ("None");
  207. BindingTestAssertions.CheckNetTcpBinding (
  208. new NetTcpBinding (SecurityMode.None), SecurityMode.None,
  209. false, TransferMode.Buffered, label);
  210. label.LeaveScope ();
  211. label.EnterScope ("Transport");
  212. BindingTestAssertions.CheckNetTcpBinding (
  213. new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
  214. false, TransferMode.Buffered, label);
  215. label.LeaveScope ();
  216. }
  217. [Test]
  218. [Category ("NotWorking")]
  219. public virtual void NetTcp_Binding2 ()
  220. {
  221. var label = new TestLabel ("NetTcp_Binding2");
  222. label.EnterScope ("TransportWithMessageCredential");
  223. BindingTestAssertions.CheckNetTcpBinding (
  224. new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
  225. SecurityMode.TransportWithMessageCredential, false,
  226. TransferMode.Buffered, label);
  227. label.LeaveScope ();
  228. }
  229. [Test]
  230. [Category ("NotWorking")]
  231. public virtual void NetTcp_ReliableSession ()
  232. {
  233. TestLabel label;
  234. var doc = GetMetadata ("NetTcp_ReliableSession", out label);
  235. BindingTestAssertions.NetTcpBinding (
  236. Context, doc, SecurityMode.None, true,
  237. TransferMode.Buffered, label);
  238. }
  239. [Test]
  240. public virtual void BasicHttp_Operation ()
  241. {
  242. TestLabel label;
  243. var doc = GetMetadata ("BasicHttp_Operation", out label);
  244. BindingTestAssertions.TestOperation (doc, false, label);
  245. }
  246. [Test]
  247. public virtual void NetTcp_Operation ()
  248. {
  249. TestLabel label;
  250. var doc = GetMetadata ("NetTcp_Operation", out label);
  251. BindingTestAssertions.TestOperation (doc, true, label);
  252. }
  253. [Test]
  254. public virtual void BasicHttp_Config ()
  255. {
  256. TestLabel label;
  257. XmlDocument config;
  258. var metadata = GetMetadataAndConfig (
  259. "BasicHttp_Config", out config, out label);
  260. BindingTestAssertions.AssertConfig (metadata, config, label);
  261. }
  262. [Test]
  263. public virtual void BasicHttp_Config2 ()
  264. {
  265. TestLabel label;
  266. XmlDocument config;
  267. var metadata = GetMetadataAndConfig (
  268. "BasicHttp_Config2", out config, out label);
  269. BindingTestAssertions.AssertConfig (metadata, config, label);
  270. }
  271. }
  272. }