github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/openstack/sharedfilesystems/v2/securityservices.go (about) 1 package v2 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/vnpaycloud-console/gophercloud/v2" 8 "github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/tools" 9 "github.com/vnpaycloud-console/gophercloud/v2/openstack/sharedfilesystems/v2/securityservices" 10 ) 11 12 // CreateSecurityService will create a security service with a random name. An 13 // error will be returned if the security service was unable to be created. 14 func CreateSecurityService(t *testing.T, client *gophercloud.ServiceClient) (*securityservices.SecurityService, error) { 15 if testing.Short() { 16 t.Skip("Skipping test that requires share network creation in short mode.") 17 } 18 19 securityServiceName := tools.RandomString("ACPTTEST", 16) 20 securityServiceDescription := tools.RandomString("ACPTTEST-DESC", 16) 21 t.Logf("Attempting to create security service: %s", securityServiceName) 22 23 createOpts := securityservices.CreateOpts{ 24 Name: securityServiceName, 25 Description: securityServiceDescription, 26 Type: "kerberos", 27 } 28 29 securityService, err := securityservices.Create(context.TODO(), client, createOpts).Extract() 30 if err != nil { 31 return securityService, err 32 } 33 34 return securityService, nil 35 } 36 37 // DeleteSecurityService will delete a security service. An error will occur if 38 // the security service was unable to be deleted. 39 func DeleteSecurityService(t *testing.T, client *gophercloud.ServiceClient, securityService *securityservices.SecurityService) { 40 err := securityservices.Delete(context.TODO(), client, securityService.ID).ExtractErr() 41 if err != nil { 42 t.Fatalf("Failed to delete security service %s: %v", securityService.ID, err) 43 } 44 45 t.Logf("Deleted security service: %s", securityService.ID) 46 }