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