getTestConfigForDB returns a test config for a specific database type and URL
(dbType, dbURL string)
| 120 | |
| 121 | // getTestConfigForDB returns a test config for a specific database type and URL |
| 122 | func getTestConfigForDB(dbType, dbURL string) *config.Config { |
| 123 | cfg := &config.Config{ |
| 124 | Env: constants.TestEnv, |
| 125 | SkipTestEndpointSSRFValidation: true, |
| 126 | DatabaseType: dbType, |
| 127 | DatabaseURL: dbURL, |
| 128 | JWTSecret: "test-secret", |
| 129 | ClientID: "test-client-id", |
| 130 | ClientSecret: "test-client-secret", |
| 131 | AllowedOrigins: []string{"http://localhost:3000"}, |
| 132 | JWTType: "HS256", |
| 133 | AdminSecret: "test-admin-secret", |
| 134 | TwilioAPISecret: "test-twilio-api-secret", |
| 135 | TwilioAPIKey: "test-twilio-api-key", |
| 136 | TwilioAccountSID: "test-twilio-account-sid", |
| 137 | TwilioSender: "test-twilio-sender", |
| 138 | DefaultRoles: []string{"user"}, |
| 139 | Roles: []string{ |
| 140 | "user", "admin", "viewer", "editor", |
| 141 | "accountant", "auditor", |
| 142 | "blocked-role", "other-role", |
| 143 | }, |
| 144 | EnableSignup: true, |
| 145 | EnableBasicAuthentication: true, |
| 146 | EnableMobileBasicAuthentication: true, |
| 147 | EnableLoginPage: true, |
| 148 | EnableStrongPassword: true, |
| 149 | IsSMSServiceEnabled: true, |
| 150 | } |
| 151 | |
| 152 | // MongoDB, ArangoDB, Cassandra/Scylla require DatabaseName (keyspace / DB name); see storage New(). |
| 153 | if dbType == constants.DbTypeMongoDB || dbType == constants.DbTypeArangoDB || |
| 154 | dbType == constants.DbTypeScyllaDB || dbType == constants.DbTypeCassandraDB { |
| 155 | cfg.DatabaseName = "authorizer_test" |
| 156 | } |
| 157 | |
| 158 | // Set Couchbase-specific config |
| 159 | if dbType == constants.DbTypeCouchbaseDB { |
| 160 | cfg.DatabaseUsername = "Administrator" |
| 161 | cfg.DatabasePassword = "password" |
| 162 | cfg.CouchBaseBucket = "authorizer_test" |
| 163 | } |
| 164 | |
| 165 | // DynamoDB Local (and AWS) expect a region for signing; avoid picking up real AWS keys in tests. |
| 166 | if dbType == constants.DbTypeDynamoDB { |
| 167 | cfg.AWSRegion = "us-east-1" |
| 168 | } |
| 169 | |
| 170 | return cfg |
| 171 | } |
| 172 | |
| 173 | // initTestSetup initializes the test setup |
| 174 | func initTestSetup(t *testing.T, cfg *config.Config) *testSetup { |
no outgoing calls