ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 1 | package v2 |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/gophercloud/gophercloud" |
| 7 | "github.com/gophercloud/gophercloud/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 | t.Logf("Attempting to create security service: %s", securityServiceName) |
| 20 | |
| 21 | createOpts := securityservices.CreateOpts{ |
| 22 | Name: securityServiceName, |
| 23 | Type: "kerberos", |
| 24 | } |
| 25 | |
| 26 | securityService, err := securityservices.Create(client, createOpts).Extract() |
| 27 | if err != nil { |
| 28 | return securityService, err |
| 29 | } |
| 30 | |
| 31 | return securityService, nil |
| 32 | } |
| 33 | |
ehdou | 894b50d | 2017-01-07 00:38:03 +0200 | [diff] [blame] | 34 | // DeleteSecurityService will delete a security service. An error will occur if |
| 35 | // the security service was unable to be deleted. |
| 36 | func DeleteSecurityService(t *testing.T, client *gophercloud.ServiceClient, securityService *securityservices.SecurityService) { |
| 37 | err := securityservices.Delete(client, securityService.ID).ExtractErr() |
| 38 | if err != nil { |
| 39 | t.Fatalf("Failed to delete security service %s: %v", securityService.ID, err) |
| 40 | } |
| 41 | |
| 42 | t.Logf("Deleted security service: %s", securityService.ID) |
| 43 | } |
| 44 | |
ehdou | b5066cd | 2016-11-10 22:15:42 +0200 | [diff] [blame] | 45 | // PrintSecurityService will print a security service and all of its attributes. |
| 46 | func PrintSecurityService(t *testing.T, securityService *securityservices.SecurityService) { |
| 47 | t.Logf("ID: %s", securityService.ID) |
| 48 | t.Logf("Project ID: %s", securityService.ProjectID) |
| 49 | t.Logf("Domain: %s", securityService.Domain) |
| 50 | t.Logf("Status: %s", securityService.Status) |
| 51 | t.Logf("Type: %s", securityService.Type) |
| 52 | t.Logf("Name: %s", securityService.Name) |
| 53 | t.Logf("Description: %s", securityService.Description) |
| 54 | t.Logf("DNS IP: %s", securityService.DNSIP) |
| 55 | t.Logf("User: %s", securityService.User) |
| 56 | t.Logf("Password: %s", securityService.Password) |
| 57 | t.Logf("Server: %s", securityService.Server) |
| 58 | t.Logf("Created at: %v", securityService.CreatedAt) |
| 59 | t.Logf("Updated at: %v", securityService.UpdatedAt) |
| 60 | } |