blob: 265323d4792790524f78b0f51b3f9c6e28c65379 [file] [log] [blame]
ehdoub5066cd2016-11-10 22:15:42 +02001package v2
2
3import (
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.
13func 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
ehdou894b50d2017-01-07 00:38:03 +020034// DeleteSecurityService will delete a security service. An error will occur if
35// the security service was unable to be deleted.
36func 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
ehdoub5066cd2016-11-10 22:15:42 +020045// PrintSecurityService will print a security service and all of its attributes.
46func 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}