File: securityservices.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 0.0~git20180917.45f1c769-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,768 kB
  • sloc: sh: 98; makefile: 14
file content (60 lines) | stat: -rw-r--r-- 2,272 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package v2

import (
	"testing"

	"github.com/gophercloud/gophercloud"
	"github.com/gophercloud/gophercloud/acceptance/tools"
	"github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/securityservices"
)

// CreateSecurityService will create a security service with a random name. An
// error will be returned if the security service was unable to be created.
func CreateSecurityService(t *testing.T, client *gophercloud.ServiceClient) (*securityservices.SecurityService, error) {
	if testing.Short() {
		t.Skip("Skipping test that requires share network creation in short mode.")
	}

	securityServiceName := tools.RandomString("ACPTTEST", 16)
	t.Logf("Attempting to create security service: %s", securityServiceName)

	createOpts := securityservices.CreateOpts{
		Name: securityServiceName,
		Type: "kerberos",
	}

	securityService, err := securityservices.Create(client, createOpts).Extract()
	if err != nil {
		return securityService, err
	}

	return securityService, nil
}

// DeleteSecurityService will delete a security service. An error will occur if
// the security service was unable to be deleted.
func DeleteSecurityService(t *testing.T, client *gophercloud.ServiceClient, securityService *securityservices.SecurityService) {
	err := securityservices.Delete(client, securityService.ID).ExtractErr()
	if err != nil {
		t.Fatalf("Failed to delete security service %s: %v", securityService.ID, err)
	}

	t.Logf("Deleted security service: %s", securityService.ID)
}

// PrintSecurityService will print a security service and all of its attributes.
func PrintSecurityService(t *testing.T, securityService *securityservices.SecurityService) {
	t.Logf("ID: %s", securityService.ID)
	t.Logf("Project ID: %s", securityService.ProjectID)
	t.Logf("Domain: %s", securityService.Domain)
	t.Logf("Status: %s", securityService.Status)
	t.Logf("Type: %s", securityService.Type)
	t.Logf("Name: %s", securityService.Name)
	t.Logf("Description: %s", securityService.Description)
	t.Logf("DNS IP: %s", securityService.DNSIP)
	t.Logf("User: %s", securityService.User)
	t.Logf("Password: %s", securityService.Password)
	t.Logf("Server: %s", securityService.Server)
	t.Logf("Created at: %v", securityService.CreatedAt)
	t.Logf("Updated at: %v", securityService.UpdatedAt)
}