Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove file-path TLS references and usage #100

Merged
merged 1 commit into from
Jun 6, 2024
Merged
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ datasources:
port: 8812
username: admin
tlsMode: disable
# tlsCACertFile: <string>
# timeout: <seconds>
# queryTimeout: <seconds>
maxOpenConnections: 100
Expand Down
14 changes: 0 additions & 14 deletions pkg/plugin/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,6 @@ A24pDtdOHydwtSB5+zFqFLfmVZplQM/g5kb4so70Yw==
connStr += fmt.Sprintf(" sslcert='%s' sslkey='%s'", escape(tlsClientCert), escape(tlsClientKey))
}

} else if settings.ConfigurationMethod == "file-path" {
// Attach root certificate if provided
if settings.TlsCACertFile != "" {
log.DefaultLogger.Debug("Setting server root certificate", "tlsRootCertFile", settings.TlsCACertFile)
connStr += fmt.Sprintf(" sslrootcert='%s'", escape(settings.TlsCACertFile))
}

// Attach client certificate and key if both are provided
if settings.TlsClientCertFile != "" && settings.TlsClientKeyFile != "" {
log.DefaultLogger.Debug("Setting TLS/SSL client auth", "tlsCertFile", settings.TlsClientCertFile, "tlsKeyFile", settings.TlsClientKeyFile)
connStr += fmt.Sprintf(" sslcert='%s' sslkey='%s'", escape(settings.TlsClientCertFile), escape(settings.TlsClientKeyFile))
} else if settings.TlsClientCertFile != "" || settings.TlsClientKeyFile != "" {
return "", fmt.Errorf("TLS/SSL client certificate and key files must both be specified")
}
} else if settings.ConfigurationMethod != "" {
return "", errors.New(fmt.Sprintf("invalid ssl configuration method: %s", settings.ConfigurationMethod))
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/plugin/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type Settings struct {
TlsMode string `json:"tlsMode"`
ConfigurationMethod string `json:"tlsConfigurationMethod"`

TlsCACertFile string `json:"tlsCaCertFile"`
TlsClientCertFile string `json:"tlsClientCertFile"`
TlsClientKeyFile string `json:"tlsClientKeyFile"`
}
Expand Down Expand Up @@ -130,9 +129,6 @@ func LoadSettings(config backend.DataSourceInstanceSettings) (settings Settings,
settings.TlsMode = jsonData["tlsMode"].(string)
}

if jsonData["tlsCACertFile"] != nil {
settings.TlsCACertFile = jsonData["tlsCACertFile"].(string)
}
if jsonData["tlsClientCertFile"] != nil {
settings.TlsClientCertFile = jsonData["tlsClientCertFile"].(string)
}
Expand Down
41 changes: 0 additions & 41 deletions pkg/plugin/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,47 +88,6 @@ func TestLoadSettings(t *testing.T) {
},
expectedErr: nil,
},
{
name: "should parse json with tls and file-path mode",
args: args{
config: backend.DataSourceInstanceSettings{
UID: "ds-uid",
JSONData: []byte(`{ "server": "test", "port": 8812, "username": "john",
"enableSecureSocksProxy": true, "tlsMode": "verify-ca", "tlsConfigurationMethod": "file-path",
"tlsCACertFile": "/var/caCertFile", "tlsClientCertFile": "/var/clientCertFile", "tlsClientKeyFile": "/var/clientKeyFile",
"timeout": 10, "queryTimeout": 50, "maxOpenConnections": 100, "maxIdleConnections": 100, "maxConnectionLifetime": 14400 }`),
DecryptedSecureJSONData: map[string]string{"password": "rambo", "secureSocksProxyPassword": "test"},
},
},
expectedSettings: Settings{
Server: "test",
Port: 8812,
Username: "john",
Password: "rambo",
TlsCACertFile: "/var/caCertFile",
TlsClientCertFile: "/var/clientCertFile",
TlsClientKeyFile: "/var/clientKeyFile",
Timeout: 10,
QueryTimeout: 50,
MaxOpenConnections: 100,
MaxIdleConnections: 100,
MaxConnectionLifetime: 14400,
TlsMode: "verify-ca",
ConfigurationMethod: "file-path",
ProxyOptions: &proxy.Options{
Enabled: true,
Auth: &proxy.AuthOptions{
Username: "ds-uid",
Password: "test",
},
Timeouts: &proxy.TimeoutOptions{
Timeout: 10 * time.Second,
KeepAlive: proxy.DefaultTimeoutOptions.KeepAlive,
},
},
},
expectedErr: nil,
},
{
name: "should converting string values to the correct type",
args: args{
Expand Down
1 change: 0 additions & 1 deletion provisioning/datasources/questdb_questdb_datasource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ datasources:
port: 8812
username: admin
tlsMode: disable
# tlsCACertFile: <string>
# timeout: <seconds>
# queryTimeout: <seconds>
maxOpenConnections: 100
Expand Down
5 changes: 0 additions & 5 deletions src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ export const Components = {
placeholder: 'Client Key. Begins with -----BEGIN RSA PRIVATE KEY-----',
},

TLSCACertFile: {
label: 'TLS/SSL Root Certificate File',
placeholder:
'If the selected TLS/SSL mode requires a server root certificate, provide the path to the file here.',
},
TLSClientCertFile: {
label: 'TLS/SSL Client Certificate File',
placeholder:
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface QuestDBConfig extends DataSourceJsonData {
tlsMode?: PostgresTLSModes;
tlsConfigurationMethod?: PostgresTLSMethods;

tlsCACertFile?: string;
tlsClientCertFile?: string;
tlsClientKeyFile?: string;
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/QuestDBConfigEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('ConfigEditor', () => {
expect(screen.getByPlaceholderText(Components.ConfigEditor.Username.placeholder)).toBeInTheDocument();
expect(screen.getByPlaceholderText(Components.ConfigEditor.Password.placeholder)).toBeInTheDocument();
expect(screen.getByText(Components.ConfigEditor.TlsMode.placeholder)).toBeInTheDocument();
expect(screen.getByText(Components.ConfigEditor.TlsMethod.label)).toBeInTheDocument();
});
it('with password', async () => {
render(
Expand Down Expand Up @@ -53,7 +54,6 @@ describe('ConfigEditor', () => {
);
expect(screen.queryByText(PostgresTLSModes.disable)).toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TlsMethod.placeholder)).not.toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACertFile.placeholder)).not.toBeInTheDocument();
expect(
screen.queryByPlaceholderText(Components.ConfigEditor.TLSClientCertFile.placeholder)
).not.toBeInTheDocument();
Expand All @@ -62,7 +62,7 @@ describe('ConfigEditor', () => {
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSClientCert.placeholder)).not.toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSClientKey.placeholder)).not.toBeInTheDocument();
});
it('with verifyCA tlsMode and fileContent tlsMethod', async () => {
it('with tlsMode and filePath tlsMethod', async () => {
render(
<ConfigEditor
{...mockConfigEditorProps()}
Expand All @@ -71,14 +71,14 @@ describe('ConfigEditor', () => {
jsonData: {
...mockConfigEditorProps().options.jsonData,
tlsMode: PostgresTLSModes.verifyCA,
tlsConfigurationMethod: PostgresTLSMethods.fileContent,
tlsConfigurationMethod: PostgresTLSMethods.filePath,
},
}}
/>
);
expect(screen.queryByText(PostgresTLSModes.verifyCA)).toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACertFile.placeholder)).not.toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACert.placeholder)).toBeInTheDocument();
expect(screen.queryByText(Components.ConfigEditor.TlsMethod.placeholder)).toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACert.placeholder)).not.toBeInTheDocument();
});

it('with verifyFull tlsMode and fileContent tlsMethod', async () => {
Expand All @@ -96,7 +96,7 @@ describe('ConfigEditor', () => {
/>
);
expect(screen.queryByText(PostgresTLSModes.verifyFull)).toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACertFile.placeholder)).not.toBeInTheDocument();
expect(screen.queryByText(Components.ConfigEditor.TlsMethod.placeholder)).toBeInTheDocument();
expect(screen.queryByPlaceholderText(Components.ConfigEditor.TLSCACert.placeholder)).toBeInTheDocument();
});

Expand Down
Loading