helpers

package
v2.2.11 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

SPDX-FileCopyrightText: (C) 2025 Intel Corporation SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestJWT

func CreateTestJWT(exp time.Time, roles []string) string

CreateTestJWT creates a JWT token for testing with specified expiration and roles

func ExtractTokenTTL

func ExtractTokenTTL(tokenString string) (time.Duration, error)

ExtractTokenTTL extracts the TTL from a JWT token for testing

func ValidateKubeconfigToken

func ValidateKubeconfigToken(kubeconfigYAML string, expectedTTL time.Duration, tolerance time.Duration) error

ValidateKubeconfigToken validates that a kubeconfig contains a token with expected TTL

Types

type MockKeycloakServer

type MockKeycloakServer struct {
	Server    *httptest.Server
	TokenTTL  time.Duration
	UserRoles []string
}

MockKeycloakServer provides a mock Keycloak server for testing

func NewMockKeycloakServer

func NewMockKeycloakServer() *MockKeycloakServer

func (*MockKeycloakServer) Close

func (m *MockKeycloakServer) Close()

func (*MockKeycloakServer) SetTokenTTL

func (m *MockKeycloakServer) SetTokenTTL(ttl time.Duration)

func (*MockKeycloakServer) SetUserRoles

func (m *MockKeycloakServer) SetUserRoles(roles []string)

func (*MockKeycloakServer) URL

func (m *MockKeycloakServer) URL() string

type MockVaultAuth

type MockVaultAuth struct {
	ClientID     string
	ClientSecret string
	ShouldFail   bool
	FailMessage  string
}

MockVaultAuth implements VaultAuth interface for testing

func NewMockVaultAuth

func NewMockVaultAuth(clientID, clientSecret string) *MockVaultAuth

func (*MockVaultAuth) GetClientCredentials

func (m *MockVaultAuth) GetClientCredentials(ctx context.Context) (string, string, error)

func (*MockVaultAuth) SetFailure

func (m *MockVaultAuth) SetFailure(shouldFail bool, message string)

Jump to

Keyboard shortcuts

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