diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 39d811b78..323eccf74 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -19,8 +19,6 @@ package integration import ( "testing" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" "github.com/opensds/opensds/test/integration/utils" ) @@ -35,60 +33,227 @@ var ( var _ = Describe("FileShare Testing", func() { Context("create FileShare ", func() { - It("TC_FS_IT_01: Create fileshare with name input ", func() { - var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_01: Create fileshare with name input", func() { + var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) Expect(resp.StatusCode).Should(Equal(202)) Expect(err).NotTo(HaveOccurred()) }) - It("TC_FS_IT_02: Create fileshare with empty file share name ", func() { - var jsonStr2 = map[string]interface{}{"name": "", "description": "This is just for testxxx", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_02: Create fileshare with empty file share name", func() { + var jsonStr2 = map[string]interface{}{"name": "", "description": "This is just for testxxx", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(400)) }) - It("TC_FS_IT_03: Create file share name with other encoding characters(except utf-8) ", func() { - var jsonStr2 = map[string]interface{}{"name": "İnanç Esasları", "description": "This is just for testxxx", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_03: Create file share name with other encoding characters(except utf-8)", func() { + var jsonStr2 = map[string]interface{}{"name": "İnanç Esasları", "description": "This is just for testxxx", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(202)) Expect(err).NotTo(HaveOccurred()) }) - It("TC_FS_IT_04: Create file share name having special characters ", func() { - var jsonStr2 = map[string]interface{}{"name": "#FileShare Code!$!test", "description": "This is just for testxxx", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_04: Create file share name having special characters", func() { + var jsonStr2 = map[string]interface{}{"name": "#FileShare Code!$!test", "description": "This is just for testxxx", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(202)) }) - It("TC_FS_IT_05: Create file share name starts with numbers ", func() { - var jsonStr2 = map[string]interface{}{"name": "123test", "description": "This is just for testxxx", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_05: Create file share name starts with numbers", func() { + var jsonStr2 = map[string]interface{}{"name": "123test", "description": "This is just for testxxx", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(202)) Expect(err).NotTo(HaveOccurred()) }) - It("TC_FS_IT_06: Create file share name length more than 255 characters ", func() { - var jsonStr2 = map[string]interface{}{"name": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "description": "This is just for testxxx", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_06: Create file share name length more than 255 characters", func() { + var jsonStr2 = map[string]interface{}{"name": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "description": "This is just for testxxx", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(400)) Expect(err).NotTo(HaveOccurred()) }) - It("TC_FS_IT_08: Create file share description with empty string ", func() { - var jsonStr2 = map[string]interface{}{"name": "abcd123", "description": "#FileShare Code!$!test", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + It("TC_FS_IT_08: Create file share description with empty string", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd123", "description": "", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_09: Create file share with description having special characters", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd124", "description": "#FileShare Code!$!test", "size": 2} url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "POST" resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) Expect(resp.StatusCode).Should(Equal(400)) Expect(err).NotTo(HaveOccurred()) }) - + It("TC_FS_IT_10: Create file share with description with more than 255 characters", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd125", "description": "abqwqwqwggg012345678910ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_11: Create file share without required parameters like fileshare name, size", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd126", "description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(400)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_12: Create file share with size with -ve number", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd127", "description": " ", "size": -2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(400)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_13: Create file share with size with +ve number", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd128", "description": " ", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_14: Create file share with size with more than total capacity", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd129", "description": " ", "size": 50} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_15: Create file share Size with 0", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd130", "description": " ", "size": 0} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(400)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_16: Create file share by specifying the File Share Id", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd131", "description": " ", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_17: Create file share by specifying the Profile id", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd132", "description": " ", "size": 2, "profileId": "0191d383-3af4-46ca-abd4-8027daa4446c"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_18: Create file share by without specifying Profile Id", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd133", "description": " ", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_19: Create file share by specifying wrong profile Id", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd134", "description": " ", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(400)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_20: Create file share by specifying Availability zone name", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd135", "description": " ", "size": 2, "availabillityZone": "default"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_21: Create file share by specifying wrong Availability zone name", func() { + var jsonStr2 = map[string]interface{}{"name": "abcd136", "description": " ", "size": 2, "availabillityZone": "default1"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(400)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_22: Update file share name with empty string", func() { + var jsonStr2 = map[string]interface{}{"name": "", "description": "This is test for case TC_FS_IT_22"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/add61d3c-5248-4dec-8d0d-9e84fd6fbbb6" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_23: Update file share name with special character string", func() { + var jsonStr2 = map[string]interface{}{"name": "$File$Test!1", "description": "This is test for case TC_FS_IT_23"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/e3885ace-23d4-4a52-a47f-0efc87b82821" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_24: Update file share name length greater than 255 characters", func() { + var jsonStr2 = map[string]interface{}{"name": "abc2abqwqwqwggg012345678910ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "description": "This is test for case TC_FS_IT_24"} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/ea5b77d1-9cb1-4ccc-b5a5-7126e1f6fffb" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_25: Update file share Description with empty string", func() { + var jsonStr2 = map[string]interface{}{"description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_26: Update file share Description with special characters", func() { + var jsonStr2 = map[string]interface{}{"description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_27: Update file share Description length more than 255 characters", func() { + var jsonStr2 = map[string]interface{}{"description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_28: Update file share Description with non utf-8 code characters", func() { + var jsonStr2 = map[string]interface{}{"description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) + It("TC_FS_IT_29: Update file share with wrong File Share Id", func() { + var jsonStr2 = map[string]interface{}{"description": " "} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" + methodName := "PUT" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + }) }) }) \ No newline at end of file diff --git a/test/integration/sample.go b/test/integration/sample.go deleted file mode 100644 index 736f68d90..000000000 --- a/test/integration/sample.go +++ /dev/null @@ -1,97 +0,0 @@ -//// Copyright 2019 The OpenSDS Authors. -//// -//// Licensed under the Apache License, Version 2.0 (the "License"); -//// you may not use this file except in compliance with the License. -//// You may obtain a copy of the License at -//// -//// http://www.apache.org/licenses/LICENSE-2.0 -//// -//// Unless required by applicable law or agreed to in writing, software -//// distributed under the License is distributed on an "AS IS" BASIS, -//// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -//// See the License for the specific language governing permissions and -//// limitations under the License. -// -//// +build integration -// -//package integration -// -//import ( -// "fmt" -// "reflect" -// "testing" -// -// . "github.com/onsi/ginkgo" -// . "github.com/onsi/gomega" -// "github.com/opensds/opensds/test/integration/utils" -//) -// -//func TestFileShare(t *testing.T) { -// RegisterFailHandler(Fail) -// RunSpecs(t, "FileShare Suite") -//} -// -//var ( -// OPERATION_FAILED = "OPERATION_FAILED" -//) -//var _ = Describe("FileShare Testing", func() { -// -// Context("create FileShare ", func() { -// -// BeforeEach(func() { -// -// }) -// AfterEach(func() { -// }) -// //It("TC_FS_IT_01: Create fileshare with name input ", func() { -// // var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} -// // -// // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" -// // methodName := "POST" -// // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) -// // -// // Expect(resp.StatusCode).Should(Equal(202)) -// // Expect(err).NotTo(HaveOccurred()) -// // -// //}) -// //It("TC_FS_IT_02: Create fileshare with duplicate name input ", func() { -// // var jsonStr2 = map[string]interface{}{"name": "sharexxx", "description": "This is just for testxxx", "size": 2} -// // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" -// // methodName := "POST" -// // utils.ConnectToHTTP(methodName, url, jsonStr2) -// //}) -// // It("has 0 units", func() {}) -// // Specify("the total amount is 0.00", func() {}) -// }) -// Context("Get FileShare ", func() { -// // var jsonStr1 = []byte(`{"name":"share2223", "description":"This is just for test222", "size": 2}`) -// // var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2} -// BeforeEach(func() { -// }) -// AfterEach(func() { -// }) -// It("TC_FS_IT_03: fileshare GET all ", func() { -// url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" -// methodName := "GET" -// resp, err := utils.ConnectToHTTP(methodName, url, nil) -// fmt.Println(reflect.TypeOf(resp.Body)) -// Expect(resp.StatusCode).Should(Equal(200)) -// Expect(err).NotTo(HaveOccurred()) -// }) -// // It("TC_FS_IT_04: fileshare GET of specific Id", func() { -// // fId := "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96/578288ba-f562-4053-a916-85e62c1128cf" -// // //fId := "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96" -// // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/578288ba-f562-4053-a916-85e62c1128cf" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" -// // methodName := "GET" -// // utils.ConnectToHTTP(methodName, url, nil) -// // // ctx, kv := utils.ConnectToDB() -// // //ret := utils.GetValueByKeyFromDB(fId) -// // //Expect(ret).ShouldNot(Equal(OPERATION_FAILED)) -// // //textFound := utils.ReadAndFindTextInFile("C:/go/src/opensds/opensds/test/integration/utils/output.json", "17c60641-63c9-4f7f-992a-c0dcd9abd502") -// // //Expect(textFound).To(BeTrue(), "Text found in the log file") -// //// -// // }) -// // // It("has 0 units", func() {}) -// // Specify("the total amount is 0.00", func() {}) -// }) -//}) \ No newline at end of file