server

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PowerOffState = "Off"
	PowerOnState  = "On"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v0.5.0

type Collection struct {
	Members []Member `json:"Members"`
}

type Member added in v0.5.0

type Member struct {
	OdataID string `json:"@odata.id"`
}

type MockServer

type MockServer struct {
	// contains filtered or unexported fields
}

func NewMockServer

func NewMockServer(log logr.Logger, addr string, opts ...Option) *MockServer

func (*MockServer) Authenticate added in v0.5.0

func (s *MockServer) Authenticate(username, password string) bool

Authenticate returns true if username/password match the stored account credentials.

func (*MockServer) GetAccountNames added in v0.5.0

func (s *MockServer) GetAccountNames() map[string]struct{}

GetAccountNames returns the set of UserName values currently in the account collection (including any created by tests). Suitable for gomega HaveKey assertions.

func (*MockServer) GetBMCSettingAttr added in v0.5.0

func (s *MockServer) GetBMCSettingAttr(managerID string) map[string]any

GetBMCSettingAttr returns the current BMC Attributes map for the given managerID (e.g. "BMC"). Returns nil if the resource cannot be loaded.

func (*MockServer) GetResourceETag added in v0.8.0

func (s *MockServer) GetResourceETag(urlPath string) string

GetResourceETag returns the current ETag for the resource at urlPath, or "".

func (*MockServer) ResetAccounts added in v0.5.0

func (s *MockServer) ResetAccounts()

ResetAccounts clears all account-collection overrides (restoring the embedded default collection) and resets the password store to defaults. Call this in AfterEach to ensure a clean slate between account-related tests.

func (*MockServer) ResetBIOSSettings added in v0.5.0

func (s *MockServer) ResetBIOSSettings(systemID string)

ResetBIOSSettings resets the BIOS attribute state on the server to defaults, clearing both current and pending attributes. systemID is the folder name under data/Systems/ (e.g. "437XR1138R2").

func (*MockServer) ResetBMCSettings added in v0.5.0

func (s *MockServer) ResetBMCSettings(managerID string)

ResetBMCSettings resets the BMC attribute state on the server to defaults, clearing both current and pending attributes. managerID is the folder name under data/Managers/ (e.g. "BMC").

func (*MockServer) ResetDellRepositoryUpdate added in v0.8.0

func (s *MockServer) ResetDellRepositoryUpdate()

ResetDellRepositoryUpdate resets Dell repository-update job state on the mock server: the job JSON, any in-flight doDellJobSteps goroutine, and the GetRepoBasedUpdateList pending-package state (back to unchecked, the initial state before any InstallFromRepository call), simulating a fresh server run (e.g. a BMC restart).

Call this in AfterEach to ensure a clean slate between Dell repository-update-related tests.

func (*MockServer) ResetUpgradeTask added in v0.5.0

func (s *MockServer) ResetUpgradeTask(resourceURIs ...string)

ResetUpgradeTask resets upgrade state on the mock server.

With no arguments it resets everything: the task JSON, any in-flight goroutine, and all System/Manager resources whose firmware version was written by a completed upgrade.

With one or more Redfish resource URIs (e.g. server.Spec.SystemURI or "/redfish/v1/Managers/BMC") it resets only the version field for those specific resources, leaving others untouched. The task JSON is also reset once no upgraded resources remain.

Call this in AfterEach to ensure a clean slate between upgrade-related tests.

func (*MockServer) SetBMCSettingAttr added in v0.8.0

func (s *MockServer) SetBMCSettingAttr(managerID, key string, value any)

SetBMCSettingAttr overwrites a single BMC attribute without bumping the ETag. Use in tests to simulate out-of-band drift invisible to the ETag fast-path.

func (*MockServer) SetResourceETag added in v0.8.0

func (s *MockServer) SetResourceETag(urlPath, etag string)

SetResourceETag sets the ETag for the resource at urlPath.

func (*MockServer) SetUnavailable added in v0.5.0

func (s *MockServer) SetUnavailable(unavailable bool)

SetUnavailable toggles the simulated-unavailable mode. When true every request returns 503 Service Unavailable, allowing tests to verify BMC connection-error handling.

func (*MockServer) Start

func (s *MockServer) Start(ctx context.Context) error

Start starts the mock server and stops on ctx cancellation.

type Option added in v0.5.0

type Option func(*MockServer)

Option is a functional option for configuring a MockServer.

func WithAuth added in v0.5.0

func WithAuth() Option

WithAuth enables HTTP Basic Auth enforcement on all non-service-root endpoints. By default the mock server accepts all requests without credentials, which is convenient for local development. Pass WithAuth() in unit-test suites to exercise the authentication path.

func WithResourceOverride added in v0.8.0

func WithResourceOverride(subPath string, fields map[string]any) Option

WithResourceOverride merges fields into the embedded JSON resource at subPath, given relative to the "data/" root (e.g. "Systems/437XR1138R2/index.json" for a System, or "Systems/437XR1138R2/Bios/index.json" for its Bios subresource), overwriting any keys present in fields while leaving the rest of the resource untouched. Nested fields (e.g. "Oem") are replaced wholesale rather than deep-merged; supply the full nested value if a sub-field needs changing. If subPath does not exist, this is a no-op.

func WithSystemOverride added in v0.8.0

func WithSystemOverride(systemID string, fields map[string]any) Option

WithSystemOverride merges fields into the System resource identified by systemID (the folder name under data/Systems/, e.g. "437XR1138R2"), overwriting any keys present in fields (e.g. "Manufacturer", "Model", "SKU"). Use this to seed System resource state a test depends on - e.g. BMC vendor detection (bmc.NewRedfishBMCClient / bmc.DefaultVendors) reads Manufacturer to dispatch to a vendor-specific client, so overriding it to "Dell Inc." obtains a Dell-capable BMC client. To override a subresource such as Bios (data/Systems/<systemID>/Bios/index.json), use WithResourceOverride directly.

Jump to

Keyboard shortcuts

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