testing

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

tokens unit tests

Index

Constants

View Source
const TokenCreationResponse = `` /* 794-byte string literal not displayed */

TokenCreationResponse is a JSON response that contains ExpectedToken and ExpectedServiceCatalog.

View Source
const TokenGetResponse = `` /* 721-byte string literal not displayed */

TokenGetResponse is a JSON response that contains ExpectedToken and ExpectedUser.

Variables

View Source
var ExpectedServiceCatalog = &tokens.ServiceCatalog{
	Entries: []tokens.CatalogEntry{
		{
			Name: "inscrutablewalrus",
			Type: "something",
			Endpoints: []tokens.Endpoint{
				{
					PublicURL: "http://something0:1234/v2/",
					Region:    "region0",
				},
				{
					PublicURL: "http://something1:1234/v2/",
					Region:    "region1",
				},
			},
		},
		{
			Name: "arbitrarypenguin",
			Type: "else",
			Endpoints: []tokens.Endpoint{
				{
					PublicURL: "http://else0:4321/v3/",
					Region:    "region0",
				},
			},
		},
	},
}

ExpectedServiceCatalog is the service catalog that should be parsed from TokenCreationResponse.

View Source
var ExpectedToken = &tokens.Token{
	ID:        "aaaabbbbccccdddd",
	ExpiresAt: time.Date(2014, time.January, 31, 15, 30, 58, 0, time.UTC),
	Tenant: tenants.Tenant{
		ID:          "fc394f2ab2df4114bde39905f800dc57",
		Name:        "test",
		Description: "There are many tenants. This one is yours.",
		Enabled:     true,
	},
}

ExpectedToken is the token that should be parsed from TokenCreationResponse.

View Source
var ExpectedUser = &tokens.User{
	ID:       "a530fefc3d594c4ba2693a4ecd6be74e",
	Name:     "apiserver",
	Roles:    []tokens.Role{{Name: "member"}, {Name: "service"}},
	UserName: "apiserver",
}

ExpectedUser is the token that should be parsed from TokenGetResponse.

Functions

func GetIsSuccessful

func GetIsSuccessful(t *testing.T, result tokens.GetResult)

GetIsSuccessful ensures that a GetResult was successful and contains the correct token and User Info.

func HandleTokenGet

func HandleTokenGet(t *testing.T, token string)

HandleTokenGet expects a Get against a /tokens handler, ensures that the request body has been constructed properly given certain auth options, and returns the result.

func HandleTokenPost

func HandleTokenPost(t *testing.T, requestJSON string)

HandleTokenPost expects a POST against a /tokens handler, ensures that the request body has been constructed properly given certain auth options, and returns the result.

func IsSuccessful

func IsSuccessful(t *testing.T, result tokens.CreateResult)

IsSuccessful ensures that a CreateResult was successful and contains the correct token and service catalog.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL