Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmweir authored and pjbgf committed May 31, 2023
1 parent 7b22fcd commit 3227616
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/auth/audit/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ func (a *AuditTest) TestRedactSensitiveData() {
name: "With no secret uri but secret base type slice",
input: []byte(`{"type":"collection","data":[{"baseType":"namespacedSecret","creatorId":null,"data":{"testfield":"somesecretencodeddata"},"id":"cattle-system:test","kind":"Opaque"}]}`),
want: []byte(fmt.Sprintf(`{"type":"collection","data":[{"baseType":"namespacedSecret","creatorId":null,"data":"%s","id":"cattle-system:test","kind":"Opaque"}]}`, redacted)),
uri: `/v3/project/local:p-12345/namespacedcertificates?limit=-1&sort=name"`,
uri: `/v3/project/local:p-12345/namespacedcertificates?limit=-1&sort=name`,
},
{
name: "With kubeconfig from generateKubeconfig action",
input: []byte(`{"baseType":"generateKubeConfigOutput","config":"apiVersion: v1\nkind: Config\nclusters:\n- name: \"somecluster-rke\"\n cluster:\n server: \"https://rancherurl.com/k8s/clusters/c-xxxxx\"\n- name: \"somecluster-rke-somecluster-rke1\"\n cluster:\n server: \"https://34.211.205.110:6443\"\n certificate-authority-data: \"somecadata\"\n\nusers:\n- name: \"somecluster-rke\"\n user:\n token: \"kubeconfig-user-12345:sometoken\"\n\n\ncontexts:\n- name: \"somecluster-rke\"\n context:\n user: \"somecluster-rke\"\n cluster: \"somecluster-rke\"\n- name: \"somecluster-rke-somecluster-rke1\"\n context:\n user: \"somecluster-rke\"\n cluster: \"somecluster-rke-somecluster-rke1\"\n\ncurrent-context: \"somecluster-rke\"\n","type":"generateKubeConfigOutput"}`),
want: []byte(fmt.Sprintf(`{"baseType":"generateKubeConfigOutput","config":"%s","type":"generateKubeConfigOutput"}`, redacted)),
uri: `/v3/clusters/c-xxxxx?action=generateKubeconfig`,
},
}
for i := range tests {
Expand Down

0 comments on commit 3227616

Please sign in to comment.