summaryrefslogtreecommitdiff
path: root/internal/storage/sql_provider_backend_mysql_test.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2025-02-23 19:22:26 +1100
committerGitHub <noreply@github.com>2025-02-23 08:22:26 +0000
commit2934c16dd0895789a75313ad661920c42e1b5169 (patch)
treeda1ac150acc1f3eb91edcf9282b899e687158fbe /internal/storage/sql_provider_backend_mysql_test.go
parent0af038e0ced689db90da480876a0bb26d78c6fb9 (diff)
feat(storage): allow postgres failover (#7775)
This allows configuring failover PostgreSQL servers. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
Diffstat (limited to 'internal/storage/sql_provider_backend_mysql_test.go')
-rw-r--r--internal/storage/sql_provider_backend_mysql_test.go60
1 files changed, 60 insertions, 0 deletions
diff --git a/internal/storage/sql_provider_backend_mysql_test.go b/internal/storage/sql_provider_backend_mysql_test.go
new file mode 100644
index 000000000..f5bd2bee7
--- /dev/null
+++ b/internal/storage/sql_provider_backend_mysql_test.go
@@ -0,0 +1,60 @@
+package storage
+
+import (
+ "crypto/tls"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+
+ "github.com/authelia/authelia/v4/internal/configuration/schema"
+)
+
+func TestNewMySQLProvider(t *testing.T) {
+ standardAddress, err := schema.NewAddress("tcp://mysql")
+ require.NoError(t, err)
+
+ testCases := []struct {
+ name string
+ have *schema.Configuration
+ }{
+ {
+ "ShouldHandleBasic",
+ &schema.Configuration{
+ Storage: schema.Storage{
+ MySQL: &schema.StorageMySQL{
+ StorageSQL: schema.StorageSQL{
+ Address: &schema.AddressTCP{Address: *standardAddress},
+ Database: "authelia",
+ },
+ },
+ },
+ },
+ },
+ {
+ "ShouldHandleTLS",
+ &schema.Configuration{
+ Storage: schema.Storage{
+ MySQL: &schema.StorageMySQL{
+ StorageSQL: schema.StorageSQL{
+ Address: &schema.AddressTCP{Address: *standardAddress},
+ Database: "authelia",
+ TLS: &schema.TLS{
+ MinimumVersion: schema.TLSVersion{Value: tls.VersionTLS12},
+ MaximumVersion: schema.TLSVersion{Value: tls.VersionTLS13},
+ SkipVerify: false,
+ ServerName: "mysql",
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ assert.NotNil(t, NewMySQLProvider(tc.have, nil))
+ })
+ }
+}