Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions internal/daemon/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,26 @@ func validateOracleConfiguration(config *cpb.Configuration) error {
}
}
}
if config.GetOracleConfiguration().GetOracleHandlers().GetEnabled() {
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters() == nil {
return errMissingConnectionParameters
}
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters().GetUsername() == "" {
return errMissingUsername
}
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters().GetServiceName() == "" {
return errMissingServiceName
}
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters().GetSecret() == nil {
return errMissingSecret
}
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters().GetSecret().GetProjectId() == "" {
return errMissingProjectID
}
if config.GetOracleConfiguration().GetOracleHandlers().GetConnectionParameters().GetSecret().GetSecretName() == "" {
return errMissingSecretName
}
}
return nil
}

Expand Down Expand Up @@ -269,6 +289,9 @@ func defaultConfig(cloudProps *cpb.CloudProperties) (*cpb.Configuration, error)
MaxExecutionThreads: DefaultOracleMetricsMaxThreads,
Queries: oracleQueries,
},
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(false),
},
},
SqlserverConfiguration: &cpb.SQLServerConfiguration{
Enabled: proto.Bool(false),
Expand Down
126 changes: 126 additions & 0 deletions internal/daemon/configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ func TestLoad(t *testing.T) {
},
},
},
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(false),
},
},
SqlserverConfiguration: &cpb.SQLServerConfiguration{
Enabled: proto.Bool(true),
Expand Down Expand Up @@ -441,6 +444,9 @@ func TestLoad(t *testing.T) {
},
},
},
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(false),
},
},
SqlserverConfiguration: &cpb.SQLServerConfiguration{
Enabled: proto.Bool(true),
Expand Down Expand Up @@ -860,6 +866,126 @@ func TestValidateOracleConfiguration(t *testing.T) {
},
want: errMissingSecretName,
},
{
name: "Oracle Handlers enabled but no connection parameters",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
},
},
},
want: errMissingConnectionParameters,
},
{
name: "Oracle Handlers enabled but username not provided",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
ServiceName: "orcl",
Secret: &cpb.SecretRef{
ProjectId: "testproject",
SecretName: "testsecret",
},
},
},
},
},
want: errMissingUsername,
},
{
name: "Oracle Handlers enabled but service_name not provided",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
Username: "testuser",
Secret: &cpb.SecretRef{
ProjectId: "testproject",
SecretName: "testsecret",
},
},
},
},
},
want: errMissingServiceName,
},
{
name: "Oracle Handlers enabled but secret not provided",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
Username: "testuser",
ServiceName: "orcl",
},
},
},
},
want: errMissingSecret,
},
{
name: "Oracle Handlers enabled but project ID not provided",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
Username: "testuser",
ServiceName: "orcl",
Secret: &cpb.SecretRef{SecretName: "testsecret"},
},
},
},
},
want: errMissingProjectID,
},
{
name: "Oracle Handlers enabled but secret name not provided",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
Username: "testuser",
ServiceName: "orcl",
Secret: &cpb.SecretRef{ProjectId: "testproject"},
},
},
},
},
want: errMissingSecretName,
},
{
name: "Oracle Handlers valid configuration",
config: &cpb.Configuration{
OracleConfiguration: &cpb.OracleConfiguration{
Enabled: proto.Bool(true),
OracleHandlers: &cpb.OracleConfiguration_OracleHandlers{
Enabled: proto.Bool(true),
ConnectionParameters: &cpb.ConnectionParameters{
Username: "testuser",
ServiceName: "orcl",
Secret: &cpb.SecretRef{
ProjectId: "testproject",
SecretName: "testsecret",
},
},
},
},
},
want: nil,
},
} {
t.Run(tc.name, func(t *testing.T) {
err := validateOracleConfiguration(tc.config)
Expand Down
5 changes: 5 additions & 0 deletions protos/configuration/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ message OracleConfiguration {
optional bool enabled = 1;
OracleDiscovery oracle_discovery = 2;
OracleMetrics oracle_metrics = 3;
message OracleHandlers {
optional bool enabled = 1;
ConnectionParameters connection_parameters = 2;
}
OracleHandlers oracle_handlers = 4;
}

message OracleDiscovery {
Expand Down