ImportTests.cs 8.8 KB

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