mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
lib/promscrape: add tests for authorization
config, which has been added in df148f48b7
This commit is contained in:
parent
4aa59cae7c
commit
27d8a5d2c0
1 changed files with 64 additions and 5 deletions
|
@ -328,6 +328,29 @@ scrape_configs:
|
||||||
- targets: ["a"]
|
- targets: ["a"]
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// Both `authorization` and `basic_auth` are set
|
||||||
|
f(`
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: x
|
||||||
|
authorization:
|
||||||
|
credentials: foobar
|
||||||
|
basic_auth:
|
||||||
|
username: foobar
|
||||||
|
static_configs:
|
||||||
|
- targets: ["a"]
|
||||||
|
`)
|
||||||
|
|
||||||
|
// Both `authorization` and `bearer_token` are set
|
||||||
|
f(`
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: x
|
||||||
|
authorization:
|
||||||
|
credentials: foobar
|
||||||
|
bearer_token: foo
|
||||||
|
static_configs:
|
||||||
|
- targets: ["a"]
|
||||||
|
`)
|
||||||
|
|
||||||
// Invalid `bearer_token_file`
|
// Invalid `bearer_token_file`
|
||||||
f(`
|
f(`
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
|
@ -773,6 +796,12 @@ scrape_configs:
|
||||||
insecure_skip_verify: true
|
insecure_skip_verify: true
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets: [1.2.3.4]
|
- targets: [1.2.3.4]
|
||||||
|
- job_name: asdf
|
||||||
|
authorization:
|
||||||
|
type: xyz
|
||||||
|
credentials: abc
|
||||||
|
static_configs:
|
||||||
|
- targets: [foobar]
|
||||||
`, []*ScrapeWork{
|
`, []*ScrapeWork{
|
||||||
{
|
{
|
||||||
ScrapeURL: "https://foo.bar:443/foo/bar?p=x%26y&p=%3D",
|
ScrapeURL: "https://foo.bar:443/foo/bar?p=x%26y&p=%3D",
|
||||||
|
@ -867,11 +896,9 @@ scrape_configs:
|
||||||
jobNameOriginal: "foo",
|
jobNameOriginal: "foo",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ScrapeURL: "http://1.2.3.4:80/metrics",
|
ScrapeURL: "http://1.2.3.4:80/metrics",
|
||||||
ScrapeInterval: 8 * time.Second,
|
ScrapeInterval: 8 * time.Second,
|
||||||
ScrapeTimeout: 34 * time.Second,
|
ScrapeTimeout: 34 * time.Second,
|
||||||
HonorLabels: false,
|
|
||||||
HonorTimestamps: false,
|
|
||||||
Labels: []prompbmarshal.Label{
|
Labels: []prompbmarshal.Label{
|
||||||
{
|
{
|
||||||
Name: "__address__",
|
Name: "__address__",
|
||||||
|
@ -902,6 +929,38 @@ scrape_configs:
|
||||||
ProxyAuthConfig: &promauth.Config{},
|
ProxyAuthConfig: &promauth.Config{},
|
||||||
jobNameOriginal: "qwer",
|
jobNameOriginal: "qwer",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ScrapeURL: "http://foobar:80/metrics",
|
||||||
|
ScrapeInterval: 8 * time.Second,
|
||||||
|
ScrapeTimeout: 34 * time.Second,
|
||||||
|
Labels: []prompbmarshal.Label{
|
||||||
|
{
|
||||||
|
Name: "__address__",
|
||||||
|
Value: "foobar",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "__metrics_path__",
|
||||||
|
Value: "/metrics",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "__scheme__",
|
||||||
|
Value: "http",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "instance",
|
||||||
|
Value: "foobar:80",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "job",
|
||||||
|
Value: "asdf",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
AuthConfig: &promauth.Config{
|
||||||
|
Authorization: "xyz abc",
|
||||||
|
},
|
||||||
|
ProxyAuthConfig: &promauth.Config{},
|
||||||
|
jobNameOriginal: "asdf",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
f(`
|
f(`
|
||||||
scrape_configs:
|
scrape_configs:
|
||||||
|
|
Loading…
Reference in a new issue