T-5: Initial Setup and SSL Helpers
Description
Create directory structure and shared helper functions for SSL integration and E2E tests. These helpers will be used by all subsequent test tasks.
Delivered Value
Reusable foundation for all SSL tests - avoids code setup duplication.
Files to Create/Modify
| File |
Action |
Description |
tests/integration/ssl/helpers.go |
Create |
Helper functions for integration tests |
tests/integration/ssl/doc.go |
Create |
Package documentation |
tests/chaos/e2e/ssl_helpers_test.go |
Create |
E2E test helpers |
Implementation
helpers.go:
package ssl
import (
"testing"
"github.com/LerianStudio/fetcher/pkg/model"
)
// SSLTestConfig define configuracao para um teste SSL
type SSLTestConfig struct {
Name string // Nome do teste
Mode string // Modo SSL a testar
ExpectSuccess bool // Se conexao deve ter sucesso
RequireCertVerify bool // Se requer verificacao de certificado
}
// GetMySQLSSLConfigs retorna configuracoes de teste para MySQL
func GetMySQLSSLConfigs() []SSLTestConfig {
return []SSLTestConfig{
{Name: "SSL_True", Mode: "true", ExpectSuccess: true},
{Name: "SSL_SkipVerify", Mode: "skip-verify", ExpectSuccess: true},
{Name: "SSL_Preferred", Mode: "preferred", ExpectSuccess: true},
}
}
// GetSQLServerSSLConfigs retorna configuracoes de teste para SQL Server
func GetSQLServerSSLConfigs() []SSLTestConfig {
return []SSLTestConfig{
{Name: "SSL_True", Mode: "true", ExpectSuccess: true},
{Name: "SSL_Strict", Mode: "strict", ExpectSuccess: true, RequireCertVerify: true},
}
}
// GetOracleSSLConfigs retorna configuracoes de teste para Oracle
// Inclui modo "verify" que requer validacao de CA chain + hostname
func GetOracleSSLConfigs() []SSLTestConfig {
return []SSLTestConfig{
{Name: "SSL_True", Mode: "true", ExpectSuccess: true},
{Name: "SSL_Enable", Mode: "enable", ExpectSuccess: true},
{Name: "SSL_Verify", Mode: "verify", ExpectSuccess: true, RequireCertVerify: true},
{Name: "SSL_SkipVerify", Mode: "skip-verify", ExpectSuccess: true},
}
}
// CreateSSLConnection cria uma conexao com configuracao SSL
func CreateSSLConnection(baseConn model.Connection, sslMode string, caCert string) model.Connection {
conn := baseConn
conn.SSL = model.SSLConfig{
Mode: sslMode,
CA: caCert,
}
return conn
}
// AssertConnectionSuccess valida que conexao foi bem sucedida
func AssertConnectionSuccess(t *testing.T, err error, config SSLTestConfig) {
t.Helper()
if config.ExpectSuccess && err != nil {
t.Errorf("Esperava conexao bem sucedida para modo %s, erro: %v", config.Mode, err)
}
if !config.ExpectSuccess && err == nil {
t.Errorf("Esperava falha de conexao para modo %s", config.Mode)
}
}
Dependencies
- Tasks 2, 3, 4 (implemented factories - required to compile tests that import datasource)
Estimate
- Size: S (small)
- Complexity: Low
Acceptance Criteria
Test Strategy
- Unit tests for helper functions
- Compilation validation
Phase 4 - Integration Tests (parallel)
Task gerada pelo Floki
Jira: FET-148
Link: https://lerian.atlassian.net/browse/FET-148
T-5: Initial Setup and SSL Helpers
Description
Create directory structure and shared helper functions for SSL integration and E2E tests. These helpers will be used by all subsequent test tasks.
Delivered Value
Reusable foundation for all SSL tests - avoids code setup duplication.
Files to Create/Modify
tests/integration/ssl/helpers.gotests/integration/ssl/doc.gotests/chaos/e2e/ssl_helpers_test.goImplementation
helpers.go:
Dependencies
Estimate
Acceptance Criteria
tests/integration/ssl/directory createdhelpers.gowith functions for all databases (MySQL, SQL Server, Oracle)GetOracleSSLConfigsincludesverifymode withRequireCertVerify: truessl_helpers_test.gofor E2E createdCreateSSLConnectionacceptscaCertfor tests with custom CATest Strategy
Phase 4 - Integration Tests (parallel)
Task gerada pelo Floki
Jira: FET-148
Link: https://lerian.atlassian.net/browse/FET-148