@@ -34,8 +34,10 @@ func withTimeout(t time.Duration, f func()) {
|
||||
}
|
||||
|
||||
func cleanDB(c *conn) error {
|
||||
tables := []string{"client", "auth_request", "auth_code",
|
||||
"refresh_token", "keys", "password"}
|
||||
tables := []string{
|
||||
"client", "auth_request", "auth_code",
|
||||
"refresh_token", "keys", "password",
|
||||
}
|
||||
|
||||
for _, tbl := range tables {
|
||||
_, err := c.Exec("delete from " + tbl)
|
||||
@@ -97,7 +99,7 @@ func getenv(key, defaultVal string) string {
|
||||
const testPostgresEnv = "DEX_POSTGRES_HOST"
|
||||
|
||||
func TestCreateDataSourceName(t *testing.T) {
|
||||
var testCases = []struct {
|
||||
testCases := []struct {
|
||||
description string
|
||||
input *Postgres
|
||||
expected string
|
||||
|
@@ -244,7 +244,6 @@ func (c *conn) CreateAuthCode(a storage.AuthCode) error {
|
||||
encoder(a.Claims.Groups), a.ConnectorID, a.ConnectorData, a.Expiry,
|
||||
a.PKCE.CodeChallenge, a.PKCE.CodeChallengeMethod,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if c.alreadyExistsCheck(err) {
|
||||
return storage.ErrAlreadyExists
|
||||
|
@@ -82,7 +82,8 @@ type migration struct {
|
||||
// All SQL flavors share migration strategies.
|
||||
var migrations = []migration{
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
create table client (
|
||||
id text not null primary key,
|
||||
secret text not null,
|
||||
@@ -170,7 +171,8 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
alter table refresh_token
|
||||
add column token text not null default '';`,
|
||||
`
|
||||
@@ -182,7 +184,8 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
create table offline_session (
|
||||
user_id text not null,
|
||||
conn_id text not null,
|
||||
@@ -192,7 +195,8 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
create table connector (
|
||||
id text not null primary key,
|
||||
type text not null,
|
||||
@@ -203,7 +207,8 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
alter table auth_code
|
||||
add column claims_preferred_username text not null default '';`,
|
||||
`
|
||||
@@ -215,14 +220,16 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
alter table offline_session
|
||||
add column connector_data bytea;
|
||||
`,
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
alter table auth_request
|
||||
modify column state varchar(4096);
|
||||
`,
|
||||
@@ -230,7 +237,8 @@ var migrations = []migration{
|
||||
flavor: &flavorMySQL,
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
create table device_request (
|
||||
user_code text not null primary key,
|
||||
device_code text not null,
|
||||
@@ -251,7 +259,8 @@ var migrations = []migration{
|
||||
},
|
||||
},
|
||||
{
|
||||
stmts: []string{`
|
||||
stmts: []string{
|
||||
`
|
||||
alter table auth_request
|
||||
add column code_challenge text not null default '';`,
|
||||
`
|
||||
|
@@ -34,7 +34,8 @@ func TestPostgresTunables(t *testing.T) {
|
||||
},
|
||||
SSL: SSL{
|
||||
Mode: pgSSLDisable, // Postgres container doesn't support SSL.
|
||||
}}
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("with nothing set, uses defaults", func(t *testing.T) {
|
||||
cfg := *baseCfg
|
||||
|
Reference in New Issue
Block a user