MCPcopy Index your code
hub / github.com/apache/cloudstack-go / TestSecurityGroupService

Function TestSecurityGroupService

test/SecurityGroupService_test.go:28–140  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26)
27
28func TestSecurityGroupService(t *testing.T) {
29 service := "SecurityGroupService"
30 response, err := readData(service)
31 if err != nil {
32 t.Skipf("Skipping test as %v", err)
33 }
34 server := CreateTestServer(t, response)
35 client := cloudstack.NewClient(server.URL, "APIKEY", "SECRETKEY", true)
36 defer server.Close()
37
38 testauthorizeSecurityGroupEgress := func(t *testing.T) {
39 if _, ok := response["authorizeSecurityGroupEgress"]; !ok {
40 t.Skipf("Skipping as no json response is provided in testdata")
41 }
42 p := client.SecurityGroup.NewAuthorizeSecurityGroupEgressParams()
43 _, err := client.SecurityGroup.AuthorizeSecurityGroupEgress(p)
44 if err != nil {
45 t.Errorf(err.Error())
46 }
47 }
48 t.Run("AuthorizeSecurityGroupEgress", testauthorizeSecurityGroupEgress)
49
50 testauthorizeSecurityGroupIngress := func(t *testing.T) {
51 if _, ok := response["authorizeSecurityGroupIngress"]; !ok {
52 t.Skipf("Skipping as no json response is provided in testdata")
53 }
54 p := client.SecurityGroup.NewAuthorizeSecurityGroupIngressParams()
55 _, err := client.SecurityGroup.AuthorizeSecurityGroupIngress(p)
56 if err != nil {
57 t.Errorf(err.Error())
58 }
59 }
60 t.Run("AuthorizeSecurityGroupIngress", testauthorizeSecurityGroupIngress)
61
62 testcreateSecurityGroup := func(t *testing.T) {
63 if _, ok := response["createSecurityGroup"]; !ok {
64 t.Skipf("Skipping as no json response is provided in testdata")
65 }
66 p := client.SecurityGroup.NewCreateSecurityGroupParams("name")
67 r, err := client.SecurityGroup.CreateSecurityGroup(p)
68 if err != nil {
69 t.Errorf(err.Error())
70 }
71 if r.Id == "" {
72 t.Errorf("Failed to parse response. ID not found")
73 }
74 }
75 t.Run("CreateSecurityGroup", testcreateSecurityGroup)
76
77 testdeleteSecurityGroup := func(t *testing.T) {
78 if _, ok := response["deleteSecurityGroup"]; !ok {
79 t.Skipf("Skipping as no json response is provided in testdata")
80 }
81 p := client.SecurityGroup.NewDeleteSecurityGroupParams()
82 _, err := client.SecurityGroup.DeleteSecurityGroup(p)
83 if err != nil {
84 t.Errorf(err.Error())
85 }

Callers

nothing calls this directly

Tested by

no test coverage detected