@@ -22,6 +22,7 @@ var _ = Describe("Generate Vector config", func() {
22
22
secretName = "es-1"
23
23
aUserName = "testuser"
24
24
aPassword = "testpass"
25
+ aToken = "my-token"
25
26
)
26
27
var (
27
28
adapter fake.Output
@@ -71,6 +72,7 @@ var _ = Describe("Generate Vector config", func() {
71
72
Data : map [string ][]byte {
72
73
constants .ClientUsername : []byte (aUserName ),
73
74
constants .ClientPassword : []byte (aPassword ),
75
+ constants .TokenKey : []byte (aToken ),
74
76
},
75
77
},
76
78
}
@@ -98,6 +100,26 @@ var _ = Describe("Generate Vector config", func() {
98
100
Expect (string (exp )).To (EqualConfigFrom (conf ))
99
101
},
100
102
Entry ("with username,password" , nil , false , framework .NoOptions , "es_with_auth_username_password.toml" ),
103
+ Entry ("with custom bearer token" , func (spec * obs.OutputSpec ) {
104
+ spec .Elasticsearch .Authentication = & obs.HTTPAuthentication {
105
+ Token : & obs.BearerToken {
106
+ From : obs .BearerTokenFromSecret ,
107
+ Secret : & obs.BearerTokenSecretKey {
108
+ Name : secretName ,
109
+ Key : constants .TokenKey ,
110
+ },
111
+ },
112
+ }
113
+ }, false , framework .NoOptions , "es_with_auth_custom_bearer_token.toml" ),
114
+ Entry ("with serviceaccount token" , func (spec * obs.OutputSpec ) {
115
+ spec .Elasticsearch .Authentication = & obs.HTTPAuthentication {
116
+ Token : & obs.BearerToken {
117
+ From : obs .BearerTokenFromServiceAccount ,
118
+ },
119
+ }
120
+ }, false , framework.Options {
121
+ framework .OptionServiceAccountTokenSecretName : "my-service-account-token" ,
122
+ }, "es_with_auth_serviceaccount_token.toml" ),
101
123
Entry ("with tls key,cert,ca-bundle" , func (spec * obs.OutputSpec ) {
102
124
spec .Elasticsearch .Authentication = nil
103
125
spec .TLS = tlsSpec
0 commit comments