credz

package
v0.0.0-...-56ce121 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package credz provides helper APIs to simplify writing credentialz test cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateHibaKeys

func CreateHibaKeys(t *testing.T, dir string)

CreateHibaKeys creates/copies hiba granted keys/certificates in the specified directory. If hiba tool is not installed on the testbed, ensure following files (generated after executing steps from https://github.com/google/hiba/blob/main/CA.md) are present in the test directory : feature/security/gnsi/credentialz/tests/hiba_authentication/ca, feature/security/gnsi/credentialz/tests/hiba_authentication/ca.pub, feature/security/gnsi/credentialz/tests/hiba_authentication/hosts/dut, feature/security/gnsi/credentialz/tests/hiba_authentication/hosts/dut.pub, feature/security/gnsi/credentialz/tests/hiba_authentication/hosts/dut-cert.pub, feature/security/gnsi/credentialz/tests/hiba_authentication/users/testuser, feature/security/gnsi/credentialz/tests/hiba_authentication/users/testuser.pub, feature/security/gnsi/credentialz/tests/hiba_authentication/users/testuser-cert.pub,

func CreateHostCertificate

func CreateHostCertificate(t *testing.T, dir string, dutKeyContents []byte)

CreateHostCertificate takes in dut key contents & creates ssh host certificate in the specified directory.

func CreateSSHKeyPair

func CreateSSHKeyPair(t *testing.T, dir, keyName string)

CreateSSHKeyPair creates ssh keypair with a filename of keyName in the specified directory. Keypairs can be created for ca/dut/testuser as per individual credentialz test requirements.

func CreateUserCertificate

func CreateUserCertificate(t *testing.T, dir, userPrincipal string)

CreateUserCertificate creates ssh user certificate in the specified directory.

func GeneratePassword

func GeneratePassword() string

GeneratePassword creates a password with following restrictions: - Must be 24-32 characters long. - Must use 4 of the 5 character classes ([a-z], [A-Z], [0-9], [!@#$%^&*(){}[]\|:;'"], [ ]).

func GetAcceptTelemetry

func GetAcceptTelemetry(t *testing.T, dut *ondatra.DUTDevice) (uint64, uint64)

GetAcceptTelemetry retrieve ssh accept telemetry counters from the dut.

func GetDutPublicKey

func GetDutPublicKey(t *testing.T, dut *ondatra.DUTDevice) []byte

GetDutPublicKey retrieve single host public key from the dut.

func GetDutTarget

func GetDutTarget(t *testing.T, dut *ondatra.DUTDevice) string

GetDutTarget returns ssh target for the dut to be used in credentialz tests.

func GetRejectTelemetry

func GetRejectTelemetry(t *testing.T, dut *ondatra.DUTDevice) (uint64, uint64)

GetRejectTelemetry retrieve ssh reject telemetry counters from the dut.

func PrettyPrint

func PrettyPrint(i interface{}) string

PrettyPrint prints rpc requests/responses in a pretty format.

func RotateAuthenticationArtifacts

func RotateAuthenticationArtifacts(t *testing.T, dut *ondatra.DUTDevice, keyDir, certDir, version string, createdOn uint64)

RotateAuthenticationArtifacts read dut key/certificate contents from the specified directory & apply it as host authentication artifacts on the dut.

func RotateAuthenticationTypes

func RotateAuthenticationTypes(t *testing.T, dut *ondatra.DUTDevice, authTypes []cpb.AuthenticationType)

RotateAuthenticationTypes apply specified host authentication types on the dut.

func RotateAuthorizedKey

func RotateAuthorizedKey(t *testing.T, dut *ondatra.DUTDevice, dir, username, version string, createdOn uint64)

RotateAuthorizedKey read user key contents from the specified directory & apply it as authorized key on the dut.

func RotateAuthorizedPrincipal

func RotateAuthorizedPrincipal(t *testing.T, dut *ondatra.DUTDevice, username, userPrincipal string)

RotateAuthorizedPrincipal apply authorized principal for the specified username on the dut.

func RotateAuthorizedPrincipalCheck

func RotateAuthorizedPrincipalCheck(t *testing.T, dut *ondatra.DUTDevice, tool cpb.AuthorizedPrincipalCheckRequest_Tool)

RotateAuthorizedPrincipalCheck apply specified authorized principal tool on the dut.

func RotateTrustedUserCA

func RotateTrustedUserCA(t *testing.T, dut *ondatra.DUTDevice, dir string)

RotateTrustedUserCA read CA key contents from the specified directory & apply it on the dut.

func RotateUserPassword

func RotateUserPassword(t *testing.T, dut *ondatra.DUTDevice, username, password, version string, createdOn uint64)

RotateUserPassword apply password for the specified username on the dut.

func SSHWithCertificate

func SSHWithCertificate(t *testing.T, target, username, dir string) (*ssh.Client, error)

SSHWithCertificate dials ssh with user certificate to be used in credentialz tests.

func SSHWithKey

func SSHWithKey(t *testing.T, target, username, dir string) (*ssh.Client, error)

SSHWithKey dials ssh with key based authentication to be used in credentialz tests.

func SSHWithPassword

func SSHWithPassword(target, username, password string) (*ssh.Client, error)

SSHWithPassword dials ssh with password based authentication to be used in credentialz tests.

func SetupUser

func SetupUser(t *testing.T, dut *ondatra.DUTDevice, username string)

SetupUser setup user for credentialz tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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