Skip to content

Commit 53fc425

Browse files
Fix lint and changelog issues
1 parent 3aeab93 commit 53fc425

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

.changelog/3682.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
streamconnection/resource_stream_connection: Add new authentication mechanism(OIDC) to the Kafka connection
3+
```

internal/service/streamconnection/model_stream_connection.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ func NewStreamConnectionReq(ctx context.Context, plan *TFStreamConnectionModel)
3030
Mechanism: authenticationModel.Mechanism.ValueStringPointer(),
3131
Password: authenticationModel.Password.ValueStringPointer(),
3232
Username: authenticationModel.Username.ValueStringPointer(),
33-
TokenEndpointUrl: authenticationModel.TokenEndpointUrl.ValueStringPointer(),
34-
ClientId: authenticationModel.ClientId.ValueStringPointer(),
33+
TokenEndpointUrl: authenticationModel.TokenEndpointURL.ValueStringPointer(),
34+
ClientId: authenticationModel.ClientID.ValueStringPointer(),
3535
ClientSecret: authenticationModel.ClientSecret.ValueStringPointer(),
3636
Scope: authenticationModel.Scope.ValueStringPointer(),
3737
SaslOauthbearerExtensions: authenticationModel.SaslOauthbearerExtensions.ValueStringPointer(),
38-
HttpsCaPem: authenticationModel.HttpsCaPem.ValueStringPointer(),
38+
HttpsCaPem: authenticationModel.HTTPSCaPem.ValueStringPointer(),
3939
}
4040
}
4141
if !plan.Security.IsNull() {
@@ -223,11 +223,11 @@ func newTFConnectionAuthenticationModel(ctx context.Context, currAuthConfig *typ
223223
resultAuthModel := TFConnectionAuthenticationModel{
224224
Mechanism: types.StringPointerValue(authResp.Mechanism),
225225
Username: types.StringPointerValue(authResp.Username),
226-
TokenEndpointUrl: types.StringPointerValue(authResp.TokenEndpointUrl),
227-
ClientId: types.StringPointerValue(authResp.ClientId),
226+
TokenEndpointURL: types.StringPointerValue(authResp.TokenEndpointUrl),
227+
ClientID: types.StringPointerValue(authResp.ClientId),
228228
Scope: types.StringPointerValue(authResp.Scope),
229229
SaslOauthbearerExtensions: types.StringPointerValue(authResp.SaslOauthbearerExtensions),
230-
HttpsCaPem: types.StringPointerValue(authResp.HttpsCaPem),
230+
HTTPSCaPem: types.StringPointerValue(authResp.HttpsCaPem),
231231
}
232232

233233
if currAuthConfig != nil && !currAuthConfig.IsNull() { // if config is available (create & update of resource) password value is set in new state

internal/service/streamconnection/model_stream_connection_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const (
1919
authMechanism = "PLAIN"
2020
authMechanismOAuth = "OAUTHBEARER"
2121
authUsername = "user1"
22-
clientId = "auth0Client"
22+
clientID = "auth0Client"
2323
clientSecret = "secret"
24-
tokenEndpointUrl = "https://your-domain.com/oauth2/token"
24+
tokenEndpointURL = "https://your-domain.com/oauth2/token"
2525
scope = "read:messages write:messages"
2626
saslOauthbearerExtentions = "logicalCluster=cluster-kmo17m,identityPoolId=pool-l7Arl"
2727
httpsCaPem = "MHWER3343"
@@ -57,7 +57,7 @@ type sdkToTFModelTestCase struct {
5757

5858
func TestStreamConnectionSDKToTFModel(t *testing.T) {
5959
var authConfigWithPasswordDefined = tfAuthenticationObject(t, authMechanism, authUsername, "raw password")
60-
var authConfigWithOAuth = tfAuthenticationObjectForOAuth(t, authMechanismOAuth, clientId, clientSecret, tokenEndpointUrl, scope, saslOauthbearerExtentions, httpsCaPem)
60+
var authConfigWithOAuth = tfAuthenticationObjectForOAuth(t, authMechanismOAuth, clientID, clientSecret, tokenEndpointURL, scope, saslOauthbearerExtentions, httpsCaPem)
6161

6262
testCases := []sdkToTFModelTestCase{
6363
{
@@ -161,8 +161,8 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
161161
Type: admin.PtrString("Kafka"),
162162
Authentication: &admin.StreamsKafkaAuthentication{
163163
Mechanism: admin.PtrString(authMechanismOAuth),
164-
ClientId: admin.PtrString(clientId),
165-
TokenEndpointUrl: admin.PtrString(tokenEndpointUrl),
164+
ClientId: admin.PtrString(clientID),
165+
TokenEndpointUrl: admin.PtrString(tokenEndpointURL),
166166
Scope: admin.PtrString(scope),
167167
SaslOauthbearerExtensions: admin.PtrString(saslOauthbearerExtentions),
168168
HttpsCaPem: admin.PtrString(httpsCaPem),
@@ -182,7 +182,7 @@ func TestStreamConnectionSDKToTFModel(t *testing.T) {
182182
InstanceName: types.StringValue(instanceName),
183183
ConnectionName: types.StringValue(connectionName),
184184
Type: types.StringValue("Kafka"),
185-
Authentication: tfAuthenticationObjectForOAuth(t, authMechanismOAuth, clientId, clientSecret, tokenEndpointUrl, scope, saslOauthbearerExtentions, httpsCaPem), // password value is obtained from config, not api resp.
185+
Authentication: tfAuthenticationObjectForOAuth(t, authMechanismOAuth, clientID, clientSecret, tokenEndpointURL, scope, saslOauthbearerExtentions, httpsCaPem), // password value is obtained from config, not api resp.
186186
BootstrapServers: types.StringValue(bootstrapServers),
187187
Config: tfConfigMap(t, configMap),
188188
Security: tfSecurityObject(t, DummyCACert, securityProtocol),
@@ -646,12 +646,12 @@ func tfAuthenticationObjectForOAuth(t *testing.T, mechanism, clientId, clientSec
646646
t.Helper()
647647
auth, diags := types.ObjectValueFrom(t.Context(), streamconnection.ConnectionAuthenticationObjectType.AttrTypes, streamconnection.TFConnectionAuthenticationModel{
648648
Mechanism: types.StringValue(mechanism),
649-
ClientId: types.StringValue(clientId),
649+
ClientID: types.StringValue(clientId),
650650
ClientSecret: types.StringValue(clientSecret),
651-
TokenEndpointUrl: types.StringValue(tokenEndpointUrl),
651+
TokenEndpointURL: types.StringValue(tokenEndpointUrl),
652652
Scope: types.StringValue(scope),
653653
SaslOauthbearerExtensions: types.StringValue(saslOauthbearerExtensions),
654-
HttpsCaPem: types.StringValue(httpsCaPem),
654+
HTTPSCaPem: types.StringValue(httpsCaPem),
655655
})
656656
if diags.HasError() {
657657
t.Errorf("failed to create terraform data model: %s", diags.Errors()[0].Summary())

internal/service/streamconnection/resource_stream_connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ type TFConnectionAuthenticationModel struct {
5757
Mechanism types.String `tfsdk:"mechanism"`
5858
Password types.String `tfsdk:"password"`
5959
Username types.String `tfsdk:"username"`
60-
TokenEndpointUrl types.String `tfsdk:"token_endpoint_url"`
61-
ClientId types.String `tfsdk:"client_id"`
60+
TokenEndpointURL types.String `tfsdk:"token_endpoint_url"`
61+
ClientID types.String `tfsdk:"client_id"`
6262
ClientSecret types.String `tfsdk:"client_secret"`
6363
Scope types.String `tfsdk:"scope"`
6464
SaslOauthbearerExtensions types.String `tfsdk:"sasl_oauthbearer_extensions"`
65-
HttpsCaPem types.String `tfsdk:"https_ca_pem"`
65+
HTTPSCaPem types.String `tfsdk:"https_ca_pem"`
6666
}
6767

6868
var ConnectionAuthenticationObjectType = types.ObjectType{AttrTypes: map[string]attr.Type{

internal/service/streamconnection/resource_stream_connection_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,18 @@ func testCaseKafkaOAuthBearer(t *testing.T, nameSuffix string) *resource.TestCas
125125
CheckDestroy: CheckDestroyStreamConnection,
126126
Steps: []resource.TestStep{
127127
{
128-
Config: dataSourcesConfig + configureKafka(projectID, instanceName, connectionName, getKafkaAuthenticationConfig("OAUTHBEARER", "", "", tokenEndpointUrl, clientId, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem), "localhost:9092,localhost:9092", "earliest", "", false),
128+
Config: dataSourcesConfig + configureKafka(projectID, instanceName, connectionName, getKafkaAuthenticationConfig("OAUTHBEARER", "", "", tokenEndpointURL, clientID, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem), "localhost:9092,localhost:9092", "earliest", "", false),
129129
Check: resource.ComposeAggregateTestCheckFunc(
130-
checkKafkaOAuthAttributes(resourceName, instanceName, connectionName, tokenEndpointUrl, clientId, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9092,localhost:9092", "earliest", networkingTypePublic, false, true),
131-
checkKafkaOAuthAttributes(dataSourceName, instanceName, connectionName, tokenEndpointUrl, clientId, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9092,localhost:9092", "earliest", networkingTypePublic, false, false),
130+
checkKafkaOAuthAttributes(resourceName, instanceName, connectionName, tokenEndpointURL, clientID, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9092,localhost:9092", "earliest", networkingTypePublic, false, true),
131+
checkKafkaOAuthAttributes(dataSourceName, instanceName, connectionName, tokenEndpointURL, clientID, clientSecret, scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9092,localhost:9092", "earliest", networkingTypePublic, false, false),
132132
streamConnectionsAttributeChecks(pluralDataSourceName, nil, nil),
133133
),
134134
},
135135
{
136-
Config: dataSourcesWithPagination + configureKafka(projectID, instanceName, connectionName, getKafkaAuthenticationConfig("OAUTHBEARER", "", "", tokenEndpointUrl, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem), "localhost:9093", "latest", kafkaNetworkingPublic, false),
136+
Config: dataSourcesWithPagination + configureKafka(projectID, instanceName, connectionName, getKafkaAuthenticationConfig("OAUTHBEARER", "", "", tokenEndpointURL, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem), "localhost:9093", "latest", kafkaNetworkingPublic, false),
137137
Check: resource.ComposeAggregateTestCheckFunc(
138-
checkKafkaOAuthAttributes(resourceName, instanceName, connectionName, tokenEndpointUrl, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9093", "latest", networkingTypePublic, false, true),
139-
checkKafkaOAuthAttributes(dataSourceName, instanceName, connectionName, tokenEndpointUrl, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9093", "latest", networkingTypePublic, false, false),
138+
checkKafkaOAuthAttributes(resourceName, instanceName, connectionName, tokenEndpointURL, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9093", "latest", networkingTypePublic, false, true),
139+
checkKafkaOAuthAttributes(dataSourceName, instanceName, connectionName, tokenEndpointURL, "clientId2", "clientSecret", scope, saslOauthbearerExtentions, httpsCaPem, "localhost:9093", "latest", networkingTypePublic, false, false),
140140
streamConnectionsAttributeChecks(pluralDataSourceName, conversion.Pointer(2), conversion.Pointer(1)),
141141
),
142142
},

0 commit comments

Comments
 (0)