Documentation
¶
Index ¶
- Constants
- func FakeCyberArk(t testing.TB) *http.Client
- func FakeTPP(t testing.TB) (*httptest.Server, *x509.Certificate)
- func FakeVenafiCloud(t *testing.T) (_ *httptest.Server, _ *x509.Certificate, setAssert func(AssertRequest))
- func Parse(yamlmanifest string) []ctrlruntime.Object
- func TrustCA(t *testing.T, cl client.Client, cert *x509.Certificate)
- func Undent(s string) string
- func VenConnStartWatching(ctx context.Context, t *testing.T, cl client.Client)
- func WithEnvtest(t testing.TB) (_ *envtest.Environment, _ *rest.Config, kclient ctrlruntime.WithWatch)
- func WithKubeconfig(t testing.TB, restCfg *rest.Config) string
- type AssertRequest
Constants ¶
const VenConnRBAC = `` /* 1584-byte string literal not displayed */
Generated using:
helm template ./deploy/charts/venafi-kubernetes-agent -n venafi --set crds.venafiConnection.include=true --show-only templates/venafi-connection-rbac.yaml | grep -ivE '(helm|\/version)'
TODO(mael): Once we get the Makefile modules setup, we should generate this based on the Helm chart rather than having it hardcoded here. Ticket: https://venafi.atlassian.net/browse/VC-36331
Variables ¶
This section is empty.
Functions ¶
func FakeCyberArk ¶ added in v1.7.0
FakeCyberArk returns an HTTP client that will route requests to mock CyberArk Service Discovery, Identity and Discovery and Context APIs. This is useful for testing code that uses all those APIs, such as `cyberark.NewDatauploadClient`.
The environment variable `ARK_DISCOVERY_API` is set to the URL of the mock Service Discovery API, for the supplied `testing.TB` so that the client under test will use the mock Service Discovery API.
The returned HTTP client has a transport which logs requests and responses depending on log level of the logger supplied in the context.
func FakeVenafiCloud ¶
func FakeVenafiCloud(t *testing.T) (_ *httptest.Server, _ *x509.Certificate, setAssert func(AssertRequest))
func Parse ¶
func Parse(yamlmanifest string) []ctrlruntime.Object
Parses the YAML manifest. Useful for inlining YAML manifests in Go test files, to be used in conjunction with `undent`.
func TrustCA ¶ added in v1.1.0
Works with VenafiCloudClient and VenConnClient. Allows you to trust a given CA.
func Undent ¶
Undent removes leading indentation/white-space from given string and returns it as a string. Useful for inlining YAML manifests in Go code. Inline YAML manifests in the Go test files makes it easier to read the test case as opposed to reading verbose-y Go structs.
This was copied from https://github.com/jimeh/Undent/blob/main/Undent.go, all credit goes to the author, Jim Myhrberg.
For code readability purposes, it is possible to start the literal string with "\n", in which case, the first line is ignored. For example, in the following example, name and labels have the same indentation level but aren't aligned due to the leading '`':
Undent(
` name: foo
labels:
foo: bar`)
Instead, you can write a well-aligned text like this:
Undent(`
name: foo
labels:
foo: bar`)
For code readability purposes, it is also possible to not have the correct number of indentations in the last line. For example:
Undent(`
foo
bar
`)
For code readability purposes, you can also omit the indentations for empty lines. For example:
Undent(`
foo <---- 4 spaces
<---- no indentation here
bar <---- 4 spaces
`)
func VenConnStartWatching ¶ added in v1.1.0
Tests calling to VenConnClient.PostDataReadingsWithOptions must call this function to start the VenafiConnection watcher. If you don't call this, the test will stall.
func WithEnvtest ¶
func WithEnvtest(t testing.TB) (_ *envtest.Environment, _ *rest.Config, kclient ctrlruntime.WithWatch)
To see the API server logs, set:
export KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true