Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide sensitive data for GetPackageRepoDetail and UpdatePackageRepository with kubeapps managed secrets #4652

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,9 @@ func TestKindClusterGetAvailablePackageSummariesForLargeReposAndTinyRedis(t *tes
for ; totalRepos < MAX_REPOS_NEVER && evictedRepos.Len() == 0; totalRepos++ {
repo := fmt.Sprintf("bitnami-%d", totalRepos)
// this is to make sure we allow enough time for repository to be created and come to ready state
if err = kubeAddHelmRepository(t, repo, "https://charts.bitnami.com/bitnami", "default", "", 0); err != nil {
if err = kubeAddHelmRepositoryAndCleanup(t, repo, "https://charts.bitnami.com/bitnami", "default", "", 0); err != nil {
t.Fatalf("%v", err)
}
t.Cleanup(func() {
if err = kubeDeleteHelmRepository(t, repo, "default"); err != nil {
t.Logf("%v", err)
}
})
// wait until this repo have been indexed and cached up to 10 minutes
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
defer cancel()
Expand Down Expand Up @@ -183,14 +178,9 @@ func TestKindClusterGetAvailablePackageSummariesForLargeReposAndTinyRedis(t *tes
for ; totalRepos < MAX_REPOS_NEVER && evictedRepos.Len() == evictedCopy.Len(); totalRepos++ {
repo := fmt.Sprintf("bitnami-%d", totalRepos)
// this is to make sure we allow enough time for repository to be created and come to ready state
if err = kubeAddHelmRepository(t, repo, "https://charts.bitnami.com/bitnami", "default", "", 0); err != nil {
if err = kubeAddHelmRepositoryAndCleanup(t, repo, "https://charts.bitnami.com/bitnami", "default", "", 0); err != nil {
t.Fatalf("%v", err)
}
t.Cleanup(func() {
if err = kubeDeleteHelmRepository(t, repo, "default"); err != nil {
t.Logf("%v", err)
}
})
// wait until this repo have been indexed and cached up to 10 minutes
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
defer cancel()
Expand Down Expand Up @@ -277,18 +267,11 @@ func TestKindClusterRepoAndChartRBAC(t *testing.T) {

for _, n := range names {
nm, ns := n.Name, n.Namespace
if err := kubeCreateNamespace(t, ns); err != nil {
if err := kubeCreateNamespaceAndCleanup(t, ns); err != nil {
t.Fatal(err)
} else if err = kubeAddHelmRepository(t, nm, podinfo_repo_url, ns, "", 0); err != nil {
} else if err = kubeAddHelmRepositoryAndCleanup(t, nm, podinfo_repo_url, ns, "", 0); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
if err = kubeDeleteHelmRepository(t, nm, ns); err != nil {
t.Logf("Failed to delete helm source due to [%v]", err)
} else if err := kubeDeleteNamespace(t, ns); err != nil {
t.Logf("Failed to delete namespace [%s] due to [%v]", ns, err)
}
})
// wait until this repo reaches 'Ready'
if err = kubeWaitUntilHelmRepositoryIsReady(t, nm, ns); err != nil {
t.Fatal(err)
Expand Down
154 changes: 102 additions & 52 deletions cmd/kubeapps-apis/plugins/fluxv2/packages/v1alpha1/global_vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2179,26 +2179,24 @@ var (
},
}

get_repo_detail_resp_6a = func(ca []byte) *corev1.GetPackageRepositoryDetailResponse {
return &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 60,
Auth: &corev1.PackageRepositoryAuth{PassCredentials: false},
TlsConfig: &corev1.PackageRepositoryTlsConfig{
InsecureSkipVerify: false,
PackageRepoTlsConfigOneOf: &corev1.PackageRepositoryTlsConfig_CertAuthority{
CertAuthority: string(ca),
},
get_repo_detail_resp_6a = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 60,
Auth: &corev1.PackageRepositoryAuth{PassCredentials: false},
TlsConfig: &corev1.PackageRepositoryTlsConfig{
InsecureSkipVerify: false,
PackageRepoTlsConfigOneOf: &corev1.PackageRepositoryTlsConfig_CertAuthority{
CertAuthority: redactedString,
},
Status: podinfo_repo_status_2,
},
}
Status: podinfo_repo_status_2,
},
}

get_repo_detail_resp_7 = &corev1.GetPackageRepositoryDetailResponse{
Expand Down Expand Up @@ -2259,20 +2257,18 @@ var (
},
}

get_repo_detail_resp_9a = func(pub, priv []byte) *corev1.GetPackageRepositoryDetailResponse {
return &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 60,
Auth: tls_auth(pub, priv),
Status: podinfo_repo_status_2,
},
}
get_repo_detail_resp_9a = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 60,
Auth: tls_auth_redacted,
Status: podinfo_repo_status_2,
},
}

get_repo_detail_req_6 = &corev1.GetPackageRepositoryDetailRequest{
Expand Down Expand Up @@ -2302,7 +2298,7 @@ var (
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 60,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_2,
},
}
Expand Down Expand Up @@ -2384,7 +2380,7 @@ var (
Type: "helm",
Url: podinfo_basic_auth_repo_url,
Interval: 600,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_1,
},
}
Expand Down Expand Up @@ -2631,6 +2627,18 @@ var (
Auth: foo_bar_auth,
}

update_repo_req_16 = &corev1.UpdatePackageRepositoryRequest{
PackageRepoRef: repoRefInReq("repo-1", "namespace-1"),
Url: "http://newurl.com",
Auth: foo_bar_auth_redacted,
}

update_repo_req_17 = &corev1.UpdatePackageRepositoryRequest{
PackageRepoRef: repoRefInReq("my-podinfo-6", "TBD"),
Url: podinfo_basic_auth_repo_url,
Auth: foo_bar_auth_redacted,
}

update_repo_resp_1 = &corev1.UpdatePackageRepositoryResponse{
PackageRepoRef: repoRef("repo-1", "namespace-1"),
}
Expand All @@ -2651,6 +2659,10 @@ var (
PackageRepoRef: repoRefWithId("my-podinfo-5"),
}

update_repo_resp_6 = &corev1.UpdatePackageRepositoryResponse{
PackageRepoRef: repoRefWithId("my-podinfo-6"),
}

update_repo_detail_1 = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Expand Down Expand Up @@ -2757,20 +2769,18 @@ var (
},
}

update_repo_detail_8 = func(pub, priv []byte) *corev1.GetPackageRepositoryDetailResponse {
return &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 600,
Auth: tls_auth(pub, priv),
Status: repo_status_pending,
},
}
update_repo_detail_8 = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 600,
Auth: tls_auth_redacted,
Status: repo_status_pending,
},
}

update_repo_detail_9 = &corev1.GetPackageRepositoryDetailResponse{
Expand All @@ -2796,7 +2806,7 @@ var (
Type: "helm",
Url: "https://example.repo.com/charts",
Interval: 600,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: repo_status_pending,
},
}
Expand All @@ -2810,7 +2820,7 @@ var (
Type: "helm",
Url: podinfo_basic_auth_repo_url,
Interval: 600,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_1,
},
}
Expand All @@ -2824,7 +2834,7 @@ var (
Type: "helm",
Url: podinfo_basic_auth_repo_url,
Interval: 600,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_1,
},
}
Expand Down Expand Up @@ -2852,7 +2862,35 @@ var (
Type: "helm",
Url: podinfo_basic_auth_repo_url,
Interval: 600,
Auth: foo_bar_auth,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_1,
},
}

update_repo_detail_15 = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: get_repo_detail_package_resp_ref,
Name: "repo-1",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: "http://newurl.com",
Interval: 600,
Auth: foo_bar_auth_redacted,
Status: repo_status_pending,
},
}

update_repo_detail_16 = &corev1.GetPackageRepositoryDetailResponse{
Detail: &corev1.PackageRepositoryDetail{
PackageRepoRef: repoRefWithId("my-podinfo-6"),
Name: "my-podinfo-6",
Description: "",
NamespaceScoped: false,
Type: "helm",
Url: podinfo_basic_auth_repo_url,
Interval: 600,
Auth: foo_bar_auth_redacted,
Status: podinfo_repo_status_1,
},
}
Expand All @@ -2867,6 +2905,16 @@ var (
},
}

foo_bar_auth_redacted = &corev1.PackageRepositoryAuth{
Type: corev1.PackageRepositoryAuth_PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
PackageRepoAuthOneOf: &corev1.PackageRepositoryAuth_UsernamePassword{
UsernamePassword: &corev1.UsernamePassword{
Username: redactedString,
Password: redactedString,
},
},
}

tls_auth = func(pub, priv []byte) *corev1.PackageRepositoryAuth {
return &corev1.PackageRepositoryAuth{
Type: corev1.PackageRepositoryAuth_PACKAGE_REPOSITORY_AUTH_TYPE_TLS,
Expand All @@ -2879,6 +2927,8 @@ var (
}
}

tls_auth_redacted = tls_auth([]byte(redactedString), []byte(redactedString))

secret_1_auth = &corev1.PackageRepositoryAuth{
Type: corev1.PackageRepositoryAuth_PACKAGE_REPOSITORY_AUTH_TYPE_BASIC_AUTH,
PackageRepoAuthOneOf: &corev1.PackageRepositoryAuth_SecretRef{
Expand Down
Loading