ImportTests.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. [Test]
  54. public virtual void BasicHttp ()
  55. {
  56. TestLabel label;
  57. var doc = GetMetadata ("BasicHttp", out label);
  58. BindingTestAssertions.BasicHttpBinding (
  59. Context, doc, BasicHttpSecurityMode.None, label);
  60. }
  61. [Test]
  62. public virtual void BasicHttp_TransportSecurity ()
  63. {
  64. TestLabel label;
  65. var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
  66. BindingTestAssertions.BasicHttpBinding (
  67. Context, doc, BasicHttpSecurityMode.Transport, label);
  68. }
  69. [Test]
  70. [Category ("NotWorking")]
  71. public virtual void BasicHttp_MessageSecurity ()
  72. {
  73. TestLabel label;
  74. var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
  75. BindingTestAssertions.BasicHttpBinding (
  76. Context, doc, BasicHttpSecurityMode.Message, label);
  77. }
  78. [Test]
  79. [Category ("NotWorking")]
  80. public virtual void BasicHttp_TransportWithMessageCredential ()
  81. {
  82. TestLabel label;
  83. var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
  84. BindingTestAssertions.BasicHttpBinding (
  85. Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
  86. }
  87. [Test]
  88. public virtual void BasicHttp_Mtom ()
  89. {
  90. TestLabel label;
  91. var doc = GetMetadata ("BasicHttp_Mtom", out label);
  92. BindingTestAssertions.BasicHttpBinding (
  93. Context, doc, WSMessageEncoding.Mtom, label);
  94. }
  95. [Test]
  96. public virtual void BasicHttp_NtlmAuth ()
  97. {
  98. TestLabel label;
  99. var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
  100. BindingTestAssertions.BasicHttpBinding (
  101. Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
  102. WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
  103. AuthenticationSchemes.Ntlm, label);
  104. }
  105. #if NET_4_5
  106. [Test]
  107. public virtual void BasicHttps ()
  108. {
  109. TestLabel label;
  110. var doc = GetMetadata ("BasicHttps", out label);
  111. BindingTestAssertions.BasicHttpsBinding (
  112. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  113. HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
  114. label);
  115. }
  116. [Test]
  117. public virtual void BasicHttps_NtlmAuth ()
  118. {
  119. TestLabel label;
  120. var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
  121. BindingTestAssertions.BasicHttpsBinding (
  122. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  123. HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
  124. label);
  125. }
  126. [Test]
  127. [Category ("NotWorking")]
  128. public virtual void BasicHttps_Certificate ()
  129. {
  130. TestLabel label;
  131. var doc = GetMetadata ("BasicHttps_Certificate", out label);
  132. BindingTestAssertions.BasicHttpsBinding (
  133. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  134. HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
  135. label);
  136. }
  137. [Test]
  138. [Category ("NotWorking")]
  139. public virtual void BasicHttps_TransportWithMessageCredential ()
  140. {
  141. TestLabel label;
  142. var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
  143. BindingTestAssertions.BasicHttpsBinding (
  144. Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
  145. WSMessageEncoding.Text, HttpClientCredentialType.None,
  146. AuthenticationSchemes.Anonymous, label);
  147. }
  148. #endif
  149. [Test]
  150. public virtual void NetTcp ()
  151. {
  152. TestLabel label;
  153. var doc = GetMetadata ("NetTcp", out label);
  154. BindingTestAssertions.NetTcpBinding (
  155. Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
  156. }
  157. [Test]
  158. public virtual void NetTcp_TransferMode ()
  159. {
  160. TestLabel label;
  161. var doc = GetMetadata ("NetTcp_TransferMode", out label);
  162. BindingTestAssertions.NetTcpBinding (
  163. Context, doc, SecurityMode.None, false,
  164. TransferMode.Streamed, label);
  165. }
  166. [Test]
  167. public virtual void NetTcp_TransportSecurity ()
  168. {
  169. TestLabel label;
  170. var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
  171. BindingTestAssertions.NetTcpBinding (
  172. Context, doc, SecurityMode.Transport, false,
  173. TransferMode.Buffered, label);
  174. }
  175. [Test]
  176. [Category ("NotWorking")]
  177. public virtual void NetTcp_MessageSecurity ()
  178. {
  179. TestLabel label;
  180. var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
  181. BindingTestAssertions.NetTcpBinding (
  182. Context, doc, SecurityMode.Message, false,
  183. TransferMode.Buffered, label);
  184. }
  185. [Test]
  186. [Category ("NotWorking")]
  187. public virtual void NetTcp_TransportWithMessageCredential ()
  188. {
  189. TestLabel label;
  190. var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
  191. BindingTestAssertions.NetTcpBinding (
  192. Context, doc, SecurityMode.TransportWithMessageCredential, false,
  193. TransferMode.Buffered, label);
  194. }
  195. [Test]
  196. public virtual void NetTcp_Binding ()
  197. {
  198. var label = new TestLabel ("NetTcp_Binding");
  199. label.EnterScope ("None");
  200. BindingTestAssertions.CheckNetTcpBinding (
  201. new NetTcpBinding (SecurityMode.None), SecurityMode.None,
  202. false, TransferMode.Buffered, label);
  203. label.LeaveScope ();
  204. label.EnterScope ("Transport");
  205. BindingTestAssertions.CheckNetTcpBinding (
  206. new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
  207. false, TransferMode.Buffered, label);
  208. label.LeaveScope ();
  209. }
  210. [Test]
  211. [Category ("NotWorking")]
  212. public virtual void NetTcp_Binding2 ()
  213. {
  214. var label = new TestLabel ("NetTcp_Binding2");
  215. label.EnterScope ("TransportWithMessageCredential");
  216. BindingTestAssertions.CheckNetTcpBinding (
  217. new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
  218. SecurityMode.TransportWithMessageCredential, false,
  219. TransferMode.Buffered, label);
  220. label.LeaveScope ();
  221. }
  222. [Test]
  223. [Category ("NotWorking")]
  224. public virtual void NetTcp_ReliableSession ()
  225. {
  226. TestLabel label;
  227. var doc = GetMetadata ("NetTcp_ReliableSession", out label);
  228. BindingTestAssertions.NetTcpBinding (
  229. Context, doc, SecurityMode.None, true,
  230. TransferMode.Buffered, label);
  231. }
  232. [Test]
  233. public virtual void BasicHttp_Operation ()
  234. {
  235. TestLabel label;
  236. var doc = GetMetadata ("BasicHttp_Operation", out label);
  237. BindingTestAssertions.TestOperation (doc, false, label);
  238. }
  239. [Test]
  240. public virtual void NetTcp_Operation ()
  241. {
  242. TestLabel label;
  243. var doc = GetMetadata ("NetTcp_Operation", out label);
  244. BindingTestAssertions.TestOperation (doc, true, label);
  245. }
  246. }
  247. }