mock

package
v0.0.0-...-851e5e8 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package errors provides errors for use in tests.

Index

Constants

View Source
const (
	StatsStart         = iota
	StatsStop          = iota
	StatsNetworkChange = iota
)

Variables

View Source
var DefaultNameserversV4 config.DNS = []string{
	"103.86.96.100",
	"103.86.99.100",
}
View Source
var DefaultNameserversV6 config.DNS = []string{
	"2400:bb40:4444::100",
	"2400:bb40:8888::100",
}
View Source
var En0Interface = net.Interface{
	Index:        1,
	MTU:          5,
	Name:         "en0",
	HardwareAddr: []byte("00:00:5e:00:53:01"),
	Flags:        net.FlagMulticast,
}
View Source
var En1Interface = net.Interface{
	Index:        1,
	MTU:          5,
	Name:         "en1",
	HardwareAddr: []byte("00:00:5e:00:53:01"),
	Flags:        net.FlagMulticast,
}
View Source
var ErrOnPurpose = errors.New("on purpose")

ErrOnPurpose is used in unit tests.

View Source
var TplNameserversV4 config.DNS = []string{
	"103.86.96.96",
	"103.86.99.99",
}
View Source
var TplNameserversV6 config.DNS = []string{
	"2400:bb40:4444::103",
	"2400:bb40:8888::103",
}

Functions

func CreateSignature

func CreateSignature(privateKey *rsa.PrivateKey, data string) (string, error)

CreateSignature signs data with RSA-SHA256 and encodes signature with Base64

func GenerateKeyPair

func GenerateKeyPair() (*rsa.PrivateKey, ssh.PublicKey, error)

GenerateKeyPair generates a new RSA key pair

func GenerateValidHeaders

func GenerateValidHeaders(privateKey *rsa.PrivateKey, data []byte) (http.Header, error)

GenerateValidHeaders generates HTTP Response headers that will be accepted in client side

Types

type ActiveVPN

type ActiveVPN struct{}

ActiveVPN stub of a github.com/NordSecurity/nordvpn-linux/daemon/vpn.VPN interface.

func (ActiveVPN) IsActive

func (ActiveVPN) IsActive() bool

func (ActiveVPN) NetworkChanged

func (ActiveVPN) NetworkChanged() error

func (ActiveVPN) Start

func (ActiveVPN) State

func (ActiveVPN) State() vpn.State

func (ActiveVPN) Stop

func (ActiveVPN) Stop() error

func (ActiveVPN) Tun

func (ActiveVPN) Tun() tunnel.T

type ConfigManager

type ConfigManager struct {
	Cfg     *config.Config
	SaveErr error
	LoadErr error
}

func NewMockConfigManager

func NewMockConfigManager() *ConfigManager

func (*ConfigManager) Load

func (m *ConfigManager) Load(c *config.Config) error

func (*ConfigManager) Reset

func (m *ConfigManager) Reset() error

func (*ConfigManager) SaveWith

func (m *ConfigManager) SaveWith(fn config.SaveFunc) error

type DNSGetter

type DNSGetter struct {
	RegisteredDomains RegisteredDomainsList
	Names             []string
}

func (*DNSGetter) Get

func (md *DNSGetter) Get(isThreatProtectionLite bool, isIPv6 bool) []string

func (*DNSGetter) LookupIP

func (md *DNSGetter) LookupIP(host string) ([]net.IP, error)

type FailingVPN

type FailingVPN struct{}

FailingVPN stub of a github.com/NordSecurity/nordvpn-linux/daemon/vpn.VPN interface.

func (FailingVPN) IsActive

func (FailingVPN) IsActive() bool

func (FailingVPN) NetworkChanged

func (FailingVPN) NetworkChanged() error

func (FailingVPN) Start

func (FailingVPN) State

func (FailingVPN) State() vpn.State

func (FailingVPN) Stop

func (FailingVPN) Stop() error

func (FailingVPN) Tun

func (FailingVPN) Tun() tunnel.T

type MeshnetAndVPN

type MeshnetAndVPN struct {
	WorkingVPN
	MeshEnableError error
}

func (*MeshnetAndVPN) Disable

func (*MeshnetAndVPN) Disable() error

func (*MeshnetAndVPN) Enable

func (w *MeshnetAndVPN) Enable(netip.Addr, string) error

func (*MeshnetAndVPN) Refresh

func (*MeshnetAndVPN) Refresh(mesh.MachineMap) error

func (*MeshnetAndVPN) StatusMap

func (*MeshnetAndVPN) StatusMap() (map[string]string, error)

type PKVault

type PKVault struct {
	PublicKey ssh.PublicKey
}

PKVault is a mock implementation of PKVault

func (PKVault) Get

func (v PKVault) Get(id string) (ssh.PublicKey, error)

Get returns loaded public key

type RegisteredDomainsList

type RegisteredDomainsList map[string][]net.IP

type RegistryMock

type RegistryMock struct {
	CurrentMachine mesh.Machine
	Peers          mesh.MachinePeers
	LocalPeers     mesh.Machines

	ListErr      error
	ConfigureErr error
	UpdateErr    error
}

func (*RegistryMock) Configure

func (r *RegistryMock) Configure(token string, id uuid.UUID, peerID uuid.UUID, peer mesh.PeerUpdateRequest) error

func (*RegistryMock) GetPeerWithIdentifier

func (r *RegistryMock) GetPeerWithIdentifier(id string) *mesh.MachinePeer

func (*RegistryMock) List

func (r *RegistryMock) List(token string, self uuid.UUID) (mesh.MachinePeers, error)

func (*RegistryMock) Local

func (r *RegistryMock) Local(token string) (mesh.Machines, error)

func (*RegistryMock) Map

func (r *RegistryMock) Map(token string, self uuid.UUID) (*mesh.MachineMap, error)

func (*RegistryMock) NotifyNewTransfer

func (*RegistryMock) NotifyNewTransfer(
	token string,
	self uuid.UUID,
	peer uuid.UUID,
	fileName string,
	fileCount int,
) error

func (*RegistryMock) Register

func (*RegistryMock) Register(token string, self mesh.Machine) (*mesh.Machine, error)

func (*RegistryMock) Unpair

func (*RegistryMock) Unpair(token string, self uuid.UUID, peer uuid.UUID) error

func (*RegistryMock) Unregister

func (*RegistryMock) Unregister(token string, self uuid.UUID) error

func (*RegistryMock) Update

func (r *RegistryMock) Update(token string, id uuid.UUID, info mesh.MachineUpdateRequest) error

type SysctlSetterMock

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

func (*SysctlSetterMock) Set

func (s *SysctlSetterMock) Set() error

func (*SysctlSetterMock) Unset

func (s *SysctlSetterMock) Unset() error

type WorkingIPv6T

type WorkingIPv6T struct{}

WorkingIPv6T stub of a github.com/NordSecurity/nordvpn-linux/tunnel.T interface.

func (WorkingIPv6T) IPs

func (WorkingIPv6T) IPs() []netip.Addr

func (WorkingIPv6T) Interface

func (WorkingIPv6T) Interface() net.Interface

func (WorkingIPv6T) TransferRates

func (WorkingIPv6T) TransferRates() (tunnel.Statistics, error)

type WorkingInactiveVPN

type WorkingInactiveVPN struct{}

func (WorkingInactiveVPN) IsActive

func (WorkingInactiveVPN) IsActive() bool

func (WorkingInactiveVPN) NetworkChanged

func (WorkingInactiveVPN) NetworkChanged() error

func (WorkingInactiveVPN) Start

func (WorkingInactiveVPN) State

func (WorkingInactiveVPN) State() vpn.State

func (WorkingInactiveVPN) Stop

func (WorkingInactiveVPN) Stop() error

func (WorkingInactiveVPN) Tun

func (WorkingInactiveVPN) Tun() tunnel.T

type WorkingT

type WorkingT struct{}

WorkingT stub of a github.com/NordSecurity/nordvpn-linux/tunnel.T interface.

func (WorkingT) IPs

func (WorkingT) IPs() []netip.Addr

func (WorkingT) Interface

func (WorkingT) Interface() net.Interface

func (WorkingT) TransferRates

func (WorkingT) TransferRates() (tunnel.Statistics, error)

type WorkingVPN

type WorkingVPN struct {
	StartErr          error
	ErrNetworkChanges error
	ExecutionStats    [statsLastValue]int
	// contains filtered or unexported fields
}

WorkingVPN stub of a github.com/NordSecurity/nordvpn-linux/daemon/vpn.VPN interface.

func (*WorkingVPN) IsActive

func (w *WorkingVPN) IsActive() bool

func (*WorkingVPN) NetworkChanged

func (w *WorkingVPN) NetworkChanged() error

func (*WorkingVPN) Start

func (*WorkingVPN) State

func (w *WorkingVPN) State() vpn.State

func (*WorkingVPN) Stop

func (w *WorkingVPN) Stop() error

func (*WorkingVPN) Tun

func (*WorkingVPN) Tun() tunnel.T

Directories

Path Synopsis
norduser

Jump to

Keyboard shortcuts

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