Allow deleting all certificate templates from GitOps (#36264)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** For #35460 # Checklist for submitter If some of the following don't apply, delete the relevant line. ## Testing - [X] Added/updated automated tests - [X] QA'd all new/changed functionality manually
This commit is contained in:
@@ -49,14 +49,20 @@ func TestGitOpsTeamSoftwareInstallers(t *testing.T) {
|
||||
{"testdata/gitops/team_software_installer_post_install_not_found.yml", "no such file or directory"},
|
||||
{"testdata/gitops/team_software_installer_no_url.yml", "at least one of hash_sha256 or url is required for each software package"},
|
||||
{"testdata/gitops/team_software_installer_no_url_multi.yml", "multi_missing_url.yml, list item #1"},
|
||||
{"testdata/gitops/team_software_installer_invalid_self_service_value.yml",
|
||||
"Couldn't edit \"../../fleetctl/testdata/gitops/team_software_installer_invalid_self_service_value.yml\" at \"software.packages.self_service\", expected type bool but got string"},
|
||||
{"testdata/gitops/team_software_installer_invalid_both_include_exclude.yml",
|
||||
`only one of "labels_exclude_any" or "labels_include_any" can be specified`},
|
||||
{
|
||||
"testdata/gitops/team_software_installer_invalid_self_service_value.yml",
|
||||
"Couldn't edit \"../../fleetctl/testdata/gitops/team_software_installer_invalid_self_service_value.yml\" at \"software.packages.self_service\", expected type bool but got string",
|
||||
},
|
||||
{
|
||||
"testdata/gitops/team_software_installer_invalid_both_include_exclude.yml",
|
||||
`only one of "labels_exclude_any" or "labels_include_any" can be specified`,
|
||||
},
|
||||
{"testdata/gitops/team_software_installer_valid_include.yml", ""},
|
||||
{"testdata/gitops/team_software_installer_valid_exclude.yml", ""},
|
||||
{"testdata/gitops/team_software_installer_invalid_unknown_label.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels."},
|
||||
{
|
||||
"testdata/gitops/team_software_installer_invalid_unknown_label.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels.",
|
||||
},
|
||||
// display_name tests
|
||||
{"testdata/gitops/team_software_installer_with_display_name.yml", ""},
|
||||
{"testdata/gitops/team_software_installer_display_name_too_long.yml", "display_name is too long (max 255 characters)"},
|
||||
@@ -140,6 +146,14 @@ func TestGitOpsTeamSoftwareInstallers(t *testing.T) {
|
||||
return []uint{}, nil
|
||||
}
|
||||
|
||||
ds.GetCertificateTemplatesByTeamIDFunc = func(ctx context.Context, teamID uint, page int, perPage int) ([]*fleet.CertificateTemplateResponseSummary, *fleet.PaginationMetadata, error) {
|
||||
return []*fleet.CertificateTemplateResponseSummary{}, &fleet.PaginationMetadata{}, nil
|
||||
}
|
||||
|
||||
ds.ListCertificateAuthoritiesFunc = func(ctx context.Context) ([]*fleet.CertificateAuthoritySummary, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
_, err = fleetctl.RunAppNoChecks([]string{"gitops", "-f", c.file})
|
||||
if c.wantErr == "" {
|
||||
require.NoError(t, err)
|
||||
@@ -175,6 +189,14 @@ func TestGitOpsTeamSoftwareInstallersQueryEnv(t *testing.T) {
|
||||
return []uint{}, nil
|
||||
}
|
||||
|
||||
ds.GetCertificateTemplatesByTeamIDFunc = func(ctx context.Context, teamID uint, page int, perPage int) ([]*fleet.CertificateTemplateResponseSummary, *fleet.PaginationMetadata, error) {
|
||||
return []*fleet.CertificateTemplateResponseSummary{}, &fleet.PaginationMetadata{}, nil
|
||||
}
|
||||
|
||||
ds.ListCertificateAuthoritiesFunc = func(ctx context.Context) ([]*fleet.CertificateAuthoritySummary, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
_, err := fleetctl.RunAppNoChecks([]string{"gitops", "-f", "../../fleetctl/testdata/gitops/team_software_installer_valid_env_query.yml"})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
@@ -316,14 +338,20 @@ func TestGitOpsNoTeamSoftwareInstallers(t *testing.T) {
|
||||
{"testdata/gitops/no_team_software_installer_uninstall_not_found.yml", "no such file or directory"},
|
||||
{"testdata/gitops/no_team_software_installer_post_install_not_found.yml", "no such file or directory"},
|
||||
{"testdata/gitops/no_team_software_installer_no_url.yml", "at least one of hash_sha256 or url is required for each software package"},
|
||||
{"testdata/gitops/no_team_software_installer_invalid_self_service_value.yml",
|
||||
"Couldn't edit \"../../fleetctl/testdata/gitops/no-team.yml\" at \"software.packages.self_service\", expected type bool but got string"},
|
||||
{"testdata/gitops/no_team_software_installer_invalid_both_include_exclude.yml",
|
||||
`only one of "labels_exclude_any" or "labels_include_any" can be specified`},
|
||||
{
|
||||
"testdata/gitops/no_team_software_installer_invalid_self_service_value.yml",
|
||||
"Couldn't edit \"../../fleetctl/testdata/gitops/no-team.yml\" at \"software.packages.self_service\", expected type bool but got string",
|
||||
},
|
||||
{
|
||||
"testdata/gitops/no_team_software_installer_invalid_both_include_exclude.yml",
|
||||
`only one of "labels_exclude_any" or "labels_include_any" can be specified`,
|
||||
},
|
||||
{"testdata/gitops/no_team_software_installer_valid_include.yml", ""},
|
||||
{"testdata/gitops/no_team_software_installer_valid_exclude.yml", ""},
|
||||
{"testdata/gitops/no_team_software_installer_invalid_unknown_label.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels."},
|
||||
{
|
||||
"testdata/gitops/no_team_software_installer_invalid_unknown_label.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels.",
|
||||
},
|
||||
// No team tests for setup experience software/script
|
||||
{"testdata/gitops/no_team_setup_software_valid.yml", ""},
|
||||
{"testdata/gitops/no_team_setup_software_invalid_script.yml", "no_such_script.sh: no such file"},
|
||||
@@ -435,22 +463,35 @@ func TestGitOpsTeamVPPApps(t *testing.T) {
|
||||
{"testdata/gitops/team_vpp_valid_empty.yml", "", time.Now().Add(-24 * time.Hour), map[string]uint{}},
|
||||
{"testdata/gitops/team_vpp_valid_app.yml", "VPP token expired", time.Now().Add(-24 * time.Hour), map[string]uint{}},
|
||||
{"testdata/gitops/team_vpp_invalid_app.yml", "app not available on vpp account", time.Now().Add(24 * time.Hour), map[string]uint{}},
|
||||
{"testdata/gitops/team_vpp_incorrect_type.yml", "Couldn't edit \"../../fleetctl/testdata/gitops/team_vpp_incorrect_type.yml\" at \"software.app_store_apps.app_store_id\", expected type string but got number",
|
||||
time.Now().Add(24 * time.Hour), map[string]uint{}},
|
||||
{
|
||||
"testdata/gitops/team_vpp_incorrect_type.yml", "Couldn't edit \"../../fleetctl/testdata/gitops/team_vpp_incorrect_type.yml\" at \"software.app_store_apps.app_store_id\", expected type string but got number",
|
||||
time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{},
|
||||
},
|
||||
{"testdata/gitops/team_vpp_empty_adamid.yml", "software app store id required", time.Now().Add(24 * time.Hour), map[string]uint{}},
|
||||
{"testdata/gitops/team_vpp_valid_app_labels_exclude_any.yml", "", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2}},
|
||||
{"testdata/gitops/team_vpp_valid_app_labels_include_any.yml", "", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2}},
|
||||
{"testdata/gitops/team_vpp_invalid_app_labels_exclude_any.yml",
|
||||
{
|
||||
"testdata/gitops/team_vpp_valid_app_labels_exclude_any.yml", "", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2},
|
||||
},
|
||||
{
|
||||
"testdata/gitops/team_vpp_valid_app_labels_include_any.yml", "", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2},
|
||||
},
|
||||
{
|
||||
"testdata/gitops/team_vpp_invalid_app_labels_exclude_any.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels.", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2}},
|
||||
{"testdata/gitops/team_vpp_invalid_app_labels_include_any.yml",
|
||||
map[string]uint{"label 1": 1, "label 2": 2},
|
||||
},
|
||||
{
|
||||
"testdata/gitops/team_vpp_invalid_app_labels_include_any.yml",
|
||||
"Please create the missing labels, or update your settings to not refer to these labels.", time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{"label 1": 1, "label 2": 2}},
|
||||
{"testdata/gitops/team_vpp_invalid_app_labels_both.yml",
|
||||
map[string]uint{"label 1": 1, "label 2": 2},
|
||||
},
|
||||
{
|
||||
"testdata/gitops/team_vpp_invalid_app_labels_both.yml",
|
||||
`only one of "labels_exclude_any" or "labels_include_any" can be specified for app store app`, time.Now().Add(24 * time.Hour),
|
||||
map[string]uint{}},
|
||||
map[string]uint{},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
@@ -511,6 +552,14 @@ func TestGitOpsTeamVPPApps(t *testing.T) {
|
||||
return found, nil
|
||||
}
|
||||
|
||||
ds.GetCertificateTemplatesByTeamIDFunc = func(ctx context.Context, teamID uint, page int, perPage int) ([]*fleet.CertificateTemplateResponseSummary, *fleet.PaginationMetadata, error) {
|
||||
return []*fleet.CertificateTemplateResponseSummary{}, &fleet.PaginationMetadata{}, nil
|
||||
}
|
||||
|
||||
ds.ListCertificateAuthoritiesFunc = func(ctx context.Context) ([]*fleet.CertificateAuthoritySummary, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
_, err = fleetctl.RunAppNoChecks([]string{"gitops", "-f", c.file})
|
||||
|
||||
if c.wantErr == "" {
|
||||
@@ -543,6 +592,14 @@ func TestGitOpsTeamVPPAndApp(t *testing.T) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
ds.GetCertificateTemplatesByTeamIDFunc = func(ctx context.Context, teamID uint, page int, perPage int) ([]*fleet.CertificateTemplateResponseSummary, *fleet.PaginationMetadata, error) {
|
||||
return []*fleet.CertificateTemplateResponseSummary{}, &fleet.PaginationMetadata{}, nil
|
||||
}
|
||||
|
||||
ds.ListCertificateAuthoritiesFunc = func(ctx context.Context) ([]*fleet.CertificateAuthoritySummary, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// The following mocks are key to this test.
|
||||
vppToken := &fleet.VPPTokenDB{
|
||||
ID: 1,
|
||||
@@ -576,8 +633,10 @@ func TestGitOpsTeamVPPAndApp(t *testing.T) {
|
||||
return []uint{}, nil
|
||||
}
|
||||
|
||||
buf, err := fleetctl.RunAppNoChecks([]string{"gitops", "-f", "../../fleetctl/testdata/gitops/global_config_vpp.yml", "-f",
|
||||
"../../fleetctl/testdata/gitops/team_vpp_valid_app.yml"})
|
||||
buf, err := fleetctl.RunAppNoChecks([]string{
|
||||
"gitops", "-f", "../../fleetctl/testdata/gitops/global_config_vpp.yml", "-f",
|
||||
"../../fleetctl/testdata/gitops/team_vpp_valid_app.yml",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.True(t, ds.UpdateVPPTokenTeamsFuncInvoked)
|
||||
assert.True(t, ds.GetVPPTokenByTeamIDFuncInvoked)
|
||||
@@ -882,6 +941,14 @@ software:
|
||||
return nil
|
||||
}
|
||||
|
||||
ds.GetCertificateTemplatesByTeamIDFunc = func(ctx context.Context, teamID uint, page int, perPage int) ([]*fleet.CertificateTemplateResponseSummary, *fleet.PaginationMetadata, error) {
|
||||
return []*fleet.CertificateTemplateResponseSummary{}, &fleet.PaginationMetadata{}, nil
|
||||
}
|
||||
|
||||
ds.ListCertificateAuthoritiesFunc = func(ctx context.Context) ([]*fleet.CertificateAuthoritySummary, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
args := []string{"gitops"}
|
||||
for _, cfg := range tt.cfgs {
|
||||
if cfg != "" {
|
||||
|
||||
Reference in New Issue
Block a user