diff --git a/config/config_test.go b/config/config_test.go index 6ccc22e847..2b3f3f7512 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1773,6 +1773,10 @@ var expectedErrors = []struct { filename: "azure_authentication_method.bad.yml", errMsg: "unknown authentication_type \"invalid\". Supported types are \"OAuth\" or \"ManagedIdentity\"", }, + { + filename: "azure_bearertoken_basicauth.bad.yml", + errMsg: "at most one of basic_auth, oauth2, bearer_token & bearer_token_file must be configured", + }, { filename: "empty_scrape_config.bad.yml", errMsg: "empty or null scrape config section", diff --git a/config/testdata/azure_bearertoken_basicauth.bad.yml b/config/testdata/azure_bearertoken_basicauth.bad.yml new file mode 100644 index 0000000000..1c22ce2e8e --- /dev/null +++ b/config/testdata/azure_bearertoken_basicauth.bad.yml @@ -0,0 +1,11 @@ +scrape_configs: + - job_name: prometheus + azure_sd_configs: + - subscription_id: 11AAAA11-A11A-111A-A111-1111A1111A11 + tenant_id: BBBB222B-B2B2-2B22-B222-2BB2222BB2B2 + client_id: 333333CC-3C33-3333-CCC3-33C3CCCCC33C + client_secret: mysecret + bearer_token: 1234 + basic_auth: + username: user + password: password diff --git a/discovery/azure/azure.go b/discovery/azure/azure.go index 098fbb4c5f..61dfc4b249 100644 --- a/discovery/azure/azure.go +++ b/discovery/azure/azure.go @@ -144,7 +144,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { return fmt.Errorf("unknown authentication_type %q. Supported types are %q or %q", c.AuthenticationMethod, authMethodOAuth, authMethodManagedIdentity) } - return nil + return c.HTTPClientConfig.Validate() } type Discovery struct {