You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

220 lines
9.8 KiB

  1. /*
  2. * MinIO .NET Library for Amazon S3 Compatible Cloud Storage,
  3. * (C) 2019, 2020 MinIO, Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. using System;
  18. using System.Net;
  19. using System.Net.Http;
  20. namespace Minio.Functional.Tests
  21. {
  22. class Program
  23. {
  24. public static void Main(string[] args)
  25. {
  26. string endPoint = null;
  27. string accessKey = null;
  28. string secretKey = null;
  29. string enableHttps = "0";
  30. string kmsEnabled = "0";
  31. bool useAWS = Environment.GetEnvironmentVariable("AWS_ENDPOINT") != null;
  32. if (Environment.GetEnvironmentVariable("SERVER_ENDPOINT") != null)
  33. {
  34. endPoint = Environment.GetEnvironmentVariable("SERVER_ENDPOINT");
  35. accessKey = Environment.GetEnvironmentVariable("ACCESS_KEY");
  36. secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
  37. enableHttps = Environment.GetEnvironmentVariable("ENABLE_HTTPS");
  38. kmsEnabled = Environment.GetEnvironmentVariable("ENABLE_KMS");
  39. }
  40. else
  41. {
  42. endPoint = "play.min.io";
  43. accessKey = "Q3AM3UQ867SPQQA43P2F";
  44. secretKey = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG";
  45. enableHttps = "1";
  46. kmsEnabled = "1";
  47. }
  48. MinioClient minioClient = null;
  49. HttpClient hc = new HttpClient();
  50. if (enableHttps == "1")
  51. // WithSSL() enables SSL support in MinIO client
  52. minioClient = new MinioClient()
  53. .WithSSL()
  54. .WithCredentials(accessKey, secretKey)
  55. .WithEndpoint(endPoint)
  56. .WithHttpClient(hc)
  57. .Build();
  58. else
  59. minioClient = new MinioClient()
  60. .WithCredentials(accessKey, secretKey)
  61. .WithEndpoint(endPoint)
  62. .WithHttpClient(hc)
  63. .Build();
  64. // Assign parameters before starting the test
  65. string bucketName = FunctionalTest.GetRandomName();
  66. string objectName = FunctionalTest.GetRandomName();
  67. string destBucketName = FunctionalTest.GetRandomName();
  68. string destObjectName = FunctionalTest.GetRandomName();
  69. // Set app Info
  70. minioClient.SetAppInfo("app-name", "app-version");
  71. // Set HTTP Tracing On
  72. // minioClient.SetTraceOn(new JsonNetLogger());
  73. // Set HTTP Tracing Off
  74. // minioClient.SetTraceOff();
  75. string runMode = Environment.GetEnvironmentVariable("MINT_MODE");
  76. if (!string.IsNullOrEmpty(runMode) && runMode == "core")
  77. {
  78. FunctionalTest.RunCoreTests(minioClient);
  79. Environment.Exit(0);
  80. }
  81. // Try catch as 'finally' section needs to run in the Functional Tests
  82. try
  83. {
  84. // Bucket notification is a minio specific feature.
  85. // If the following test is run against AWS, then the SDK throws
  86. // "Listening for bucket notification is specific only to `minio`
  87. // server endpoints".
  88. FunctionalTest.ListenBucketNotificationsAsync_Test1(minioClient).Wait();
  89. // Check if bucket exists
  90. FunctionalTest.BucketExists_Test(minioClient).Wait();
  91. FunctionalTest.MakeBucket_Test5(minioClient).Wait();
  92. if (useAWS)
  93. {
  94. FunctionalTest.MakeBucket_Test2(minioClient, useAWS).Wait();
  95. FunctionalTest.MakeBucket_Test3(minioClient, useAWS).Wait();
  96. FunctionalTest.MakeBucket_Test4(minioClient, useAWS).Wait();
  97. }
  98. // Test removal of bucket
  99. FunctionalTest.RemoveBucket_Test1(minioClient).Wait();
  100. // Test ListBuckets function
  101. FunctionalTest.ListBuckets_Test(minioClient).Wait();
  102. // Test Putobject function
  103. FunctionalTest.PutObject_Test1(minioClient).Wait();
  104. FunctionalTest.PutObject_Test2(minioClient).Wait();
  105. FunctionalTest.PutObject_Test3(minioClient).Wait();
  106. FunctionalTest.PutObject_Test4(minioClient).Wait();
  107. FunctionalTest.PutObject_Test5(minioClient).Wait();
  108. FunctionalTest.PutObject_Test7(minioClient).Wait();
  109. FunctionalTest.PutObject_Test8(minioClient).Wait();
  110. // Test StatObject function
  111. FunctionalTest.StatObject_Test1(minioClient).Wait();
  112. // Test GetObjectAsync function
  113. FunctionalTest.GetObject_Test1(minioClient).Wait();
  114. FunctionalTest.GetObject_Test2(minioClient).Wait();
  115. FunctionalTest.GetObject_Test3(minioClient).Wait();
  116. // Test File GetObject and PutObject functions
  117. FunctionalTest.FGetObject_Test1(minioClient).Wait();
  118. FunctionalTest.FPutObject_Test2(minioClient).Wait();
  119. // Test SelectObjectContentAsync function
  120. FunctionalTest.SelectObjectContent_Test(minioClient).Wait();
  121. // Test ListObjectAsync function
  122. FunctionalTest.ListObjects_Test1(minioClient).Wait();
  123. FunctionalTest.ListObjects_Test2(minioClient).Wait();
  124. FunctionalTest.ListObjects_Test3(minioClient).Wait();
  125. FunctionalTest.ListObjects_Test4(minioClient).Wait();
  126. FunctionalTest.ListObjects_Test5(minioClient).Wait();
  127. FunctionalTest.ListObjects_Test6(minioClient).Wait();
  128. // Test RemoveObjectAsync function
  129. FunctionalTest.RemoveObject_Test1(minioClient).Wait();
  130. FunctionalTest.RemoveObjects_Test2(minioClient).Wait();
  131. FunctionalTest.RemoveObjects_Test3(minioClient).Wait();
  132. // Test CopyObjectAsync function
  133. FunctionalTest.CopyObject_Test1(minioClient).Wait();
  134. FunctionalTest.CopyObject_Test2(minioClient).Wait();
  135. FunctionalTest.CopyObject_Test3(minioClient).Wait();
  136. FunctionalTest.CopyObject_Test4(minioClient).Wait();
  137. FunctionalTest.CopyObject_Test5(minioClient).Wait();
  138. FunctionalTest.CopyObject_Test6(minioClient).Wait();
  139. FunctionalTest.CopyObject_Test7(minioClient).Wait();
  140. FunctionalTest.CopyObject_Test8(minioClient).Wait();
  141. // Test SetPolicyAsync function
  142. FunctionalTest.SetBucketPolicy_Test1(minioClient).Wait();
  143. // Test Presigned Get/Put operations
  144. FunctionalTest.PresignedGetObject_Test1(minioClient).Wait();
  145. FunctionalTest.PresignedGetObject_Test2(minioClient).Wait();
  146. FunctionalTest.PresignedGetObject_Test3(minioClient).Wait();
  147. FunctionalTest.PresignedPutObject_Test1(minioClient).Wait();
  148. FunctionalTest.PresignedPutObject_Test2(minioClient).Wait();
  149. FunctionalTest.PresignedGetObject_Test1(minioClient).Wait();
  150. // FunctionalTest.PresignedPostPolicy_Test1(minioClient).Wait();
  151. // Test incomplete uploads
  152. FunctionalTest.ListIncompleteUpload_Test1(minioClient).Wait();
  153. FunctionalTest.ListIncompleteUpload_Test2(minioClient).Wait();
  154. FunctionalTest.ListIncompleteUpload_Test3(minioClient).Wait();
  155. FunctionalTest.RemoveIncompleteUpload_Test(minioClient).Wait();
  156. // Test GetBucket policy
  157. FunctionalTest.GetBucketPolicy_Test1(minioClient).Wait();
  158. // Test Object Lock Configuration
  159. FunctionalTest.ObjectLockConfigurationAsync_Test1(minioClient).Wait();
  160. // Test Bucket, Object Tags
  161. FunctionalTest.BucketTagsAsync_Test1(minioClient).Wait();
  162. FunctionalTest.ObjectTagsAsync_Test1(minioClient).Wait();
  163. // Test Bucket Lifecycle configuration
  164. FunctionalTest.BucketLifecycleAsync_Test1(minioClient).Wait();
  165. // Test encryption
  166. if (enableHttps == "1")
  167. {
  168. ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
  169. FunctionalTest.PutGetStatEncryptedObject_Test1(minioClient).Wait();
  170. FunctionalTest.PutGetStatEncryptedObject_Test2(minioClient).Wait();
  171. FunctionalTest.EncryptedCopyObject_Test1(minioClient).Wait();
  172. FunctionalTest.EncryptedCopyObject_Test2(minioClient).Wait();
  173. }
  174. if (kmsEnabled != null && kmsEnabled == "1")
  175. {
  176. FunctionalTest.PutGetStatEncryptedObject_Test3(minioClient).Wait();
  177. FunctionalTest.EncryptedCopyObject_Test3(minioClient).Wait();
  178. FunctionalTest.EncryptedCopyObject_Test4(minioClient).Wait();
  179. }
  180. }
  181. catch (System.Exception)
  182. {
  183. throw;
  184. }
  185. }
  186. }
  187. }