diff --git a/cmd/monaco/deploy/deploy.go b/cmd/monaco/deploy/deploy.go index 7c8056b0f..ec138b349 100644 --- a/cmd/monaco/deploy/deploy.go +++ b/cmd/monaco/deploy/deploy.go @@ -288,11 +288,14 @@ func validateAuthenticationWithProjectConfigs(projects []project.Project, enviro } switch conf.Type.(type) { - case config.ClassicApiType, - config.SettingsType: + case config.ClassicApiType: if environments[envName].Auth.Token == nil { return fmt.Errorf("API of type '%s' requires a token for environment '%s'", conf.Type, envName) } + case config.SettingsType: + if environments[envName].Auth.Token == nil && environments[envName].Auth.OAuth == nil { + return fmt.Errorf("API of type '%s' requires a token or OAuth for environment '%s'", conf.Type, envName) + } default: if environments[envName].Auth.OAuth == nil { return fmt.Errorf("API of type '%s' requires OAuth for environment '%s'", conf.Type, envName) diff --git a/cmd/monaco/deploy/deploy_test.go b/cmd/monaco/deploy/deploy_test.go index 37110e6a5..5173b3342 100644 --- a/cmd/monaco/deploy/deploy_test.go +++ b/cmd/monaco/deploy/deploy_test.go @@ -393,6 +393,10 @@ func Test_ValidateAuthenticationWithProjectConfigs(t *testing.T) { Type: config.ClassicApiType{}, Skip: false, } + settingsConf := config.Config{ + Type: config.SettingsType{}, + Skip: false, + } classicConfSkip := classicConf classicConfSkip.Skip = true documentConfSkip := documentConf @@ -496,6 +500,19 @@ func Test_ValidateAuthenticationWithProjectConfigs(t *testing.T) { }, "", }, + { + "OAuth manifest with settings api", + manifest.Environments{ + envId: manifest.EnvironmentDefinition{ + Name: envId, + Auth: manifest.Auth{ + OAuth: &oAuth}, + }}, + project.ConfigsPerType{ + string(config.SettingsTypeId): []config.Config{settingsConf}, + }, + "", + }, } for _, tc := range success_tests { diff --git a/cmd/monaco/download/download_configs.go b/cmd/monaco/download/download_configs.go index 45b74954f..abbce75d8 100644 --- a/cmd/monaco/download/download_configs.go +++ b/cmd/monaco/download/download_configs.go @@ -261,9 +261,6 @@ func downloadConfigs(clientSet *client.ClientSet, apisToDownload api.APIs, opts } if shouldDownloadSettings(opts) { - if opts.auth.Token == nil { - return nil, errors.New("settings client config requires token") - } log.Info("Downloading settings objects") settingCfgs, err := fn.settingsDownload(clientSet.Settings(), opts.projectName, settings.DefaultSettingsFilters, makeSettingTypes(opts.specificSchemas)...) if err != nil { diff --git a/cmd/monaco/download/download_configs_test.go b/cmd/monaco/download/download_configs_test.go index d343f0c9f..4b8e724e4 100644 --- a/cmd/monaco/download/download_configs_test.go +++ b/cmd/monaco/download/download_configs_test.go @@ -499,6 +499,17 @@ func TestDownloadConfigs_OnlyAutomationWithoutAutomationCredentials(t *testing.T assert.ErrorContains(t, err, "no OAuth credentials configured") } +func TestDownloadConfigs_OnlySettings(t *testing.T) { + opts := downloadConfigsOptions{ + onlySettings: true, + } + c := client.NewMockSettingsClient(gomock.NewController(t)) + c.EXPECT().ListSchemas(gomock.Any()).Return(dtclient.SchemaList{{SchemaId: "builtin:auto.schema"}}, nil) + c.EXPECT().List(gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes().Return([]dtclient.DownloadSettingsObject{}, nil) + err := doDownloadConfigs(testutils.CreateTestFileSystem(), &client.ClientSet{SettingsClient: c}, nil, opts) + assert.NoError(t, err) +} + func Test_downloadConfigsOptions_valid(t *testing.T) { t.Run("no error for konwn api", func(t *testing.T) { given := downloadConfigsOptions{specificAPIs: []string{"alerting-profile"}}