ImportTests.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. [Test]
  106. public virtual void BasicHttps ()
  107. {
  108. TestLabel label;
  109. var doc = GetMetadata ("BasicHttps", out label);
  110. BindingTestAssertions.BasicHttpsBinding (
  111. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  112. HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
  113. label);
  114. }
  115. [Test]
  116. public virtual void BasicHttps_NtlmAuth ()
  117. {
  118. TestLabel label;
  119. var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
  120. BindingTestAssertions.BasicHttpsBinding (
  121. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  122. HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
  123. label);
  124. }
  125. [Test]
  126. [Category ("NotWorking")]
  127. public virtual void BasicHttps_Certificate ()
  128. {
  129. TestLabel label;
  130. var doc = GetMetadata ("BasicHttps_Certificate", out label);
  131. BindingTestAssertions.BasicHttpsBinding (
  132. Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
  133. HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
  134. label);
  135. }
  136. [Test]
  137. [Category ("NotWorking")]
  138. public virtual void BasicHttps_TransportWithMessageCredential ()
  139. {
  140. TestLabel label;
  141. var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
  142. BindingTestAssertions.BasicHttpsBinding (
  143. Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
  144. WSMessageEncoding.Text, HttpClientCredentialType.None,
  145. AuthenticationSchemes.Anonymous, label);
  146. }
  147. [Test]
  148. public virtual void NetTcp ()
  149. {
  150. TestLabel label;
  151. var doc = GetMetadata ("NetTcp", out label);
  152. BindingTestAssertions.NetTcpBinding (
  153. Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
  154. }
  155. [Test]
  156. public virtual void NetTcp_TransferMode ()
  157. {
  158. TestLabel label;
  159. var doc = GetMetadata ("NetTcp_TransferMode", out label);
  160. BindingTestAssertions.NetTcpBinding (
  161. Context, doc, SecurityMode.None, false,
  162. TransferMode.Streamed, label);
  163. }
  164. [Test]
  165. public virtual void NetTcp_TransportSecurity ()
  166. {
  167. TestLabel label;
  168. var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
  169. BindingTestAssertions.NetTcpBinding (
  170. Context, doc, SecurityMode.Transport, false,
  171. TransferMode.Buffered, label);
  172. }
  173. [Test]
  174. [Category ("NotWorking")]
  175. public virtual void NetTcp_MessageSecurity ()
  176. {
  177. TestLabel label;
  178. var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
  179. BindingTestAssertions.NetTcpBinding (
  180. Context, doc, SecurityMode.Message, false,
  181. TransferMode.Buffered, label);
  182. }
  183. [Test]
  184. [Category ("NotWorking")]
  185. public virtual void NetTcp_TransportWithMessageCredential ()
  186. {
  187. TestLabel label;
  188. var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
  189. BindingTestAssertions.NetTcpBinding (
  190. Context, doc, SecurityMode.TransportWithMessageCredential, false,
  191. TransferMode.Buffered, label);
  192. }
  193. [Test]
  194. public virtual void NetTcp_Binding ()
  195. {
  196. var label = new TestLabel ("NetTcp_Binding");
  197. label.EnterScope ("None");
  198. BindingTestAssertions.CheckNetTcpBinding (
  199. new NetTcpBinding (SecurityMode.None), SecurityMode.None,
  200. false, TransferMode.Buffered, label);
  201. label.LeaveScope ();
  202. label.EnterScope ("Transport");
  203. BindingTestAssertions.CheckNetTcpBinding (
  204. new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
  205. false, TransferMode.Buffered, label);
  206. label.LeaveScope ();
  207. }
  208. [Test]
  209. [Category ("NotWorking")]
  210. public virtual void NetTcp_Binding2 ()
  211. {
  212. var label = new TestLabel ("NetTcp_Binding2");
  213. label.EnterScope ("TransportWithMessageCredential");
  214. BindingTestAssertions.CheckNetTcpBinding (
  215. new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
  216. SecurityMode.TransportWithMessageCredential, false,
  217. TransferMode.Buffered, label);
  218. label.LeaveScope ();
  219. }
  220. [Test]
  221. [Category ("NotWorking")]
  222. public virtual void NetTcp_ReliableSession ()
  223. {
  224. TestLabel label;
  225. var doc = GetMetadata ("NetTcp_ReliableSession", out label);
  226. BindingTestAssertions.NetTcpBinding (
  227. Context, doc, SecurityMode.None, true,
  228. TransferMode.Buffered, label);
  229. }
  230. }
  231. }