-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
uaa_test.go
53 lines (41 loc) · 1.14 KB
/
uaa_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package cloudfoundryreceiver
import (
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)
// Make sure we can authenticate with valid credentials
func TestValidAuthentication(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedClientConfig,
cfg.UAA.Username,
string(cfg.UAA.Password))
require.NoError(t, err)
require.NotNil(t, uaa)
// No username or password should still succeed
uaa, err = newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedClientConfig,
"",
"")
require.NoError(t, err)
require.NotNil(t, uaa)
}
// Make sure authentication fails with empty URL endpoint
func TestInvalidAuthentication(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
cfg.UAA.LimitedClientConfig.Endpoint = ""
uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedClientConfig,
cfg.UAA.Username,
string(cfg.UAA.Password))
require.EqualError(t, err, "client: missing url")
require.Nil(t, uaa)
}