Update tests
This commit is contained in:
@@ -29,7 +29,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
|
||||
|
||||
bytes, err := json.Marshal(authenticators)
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
|
||||
@@ -38,7 +38,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
|
||||
authenticatorsMap := map[string]interface{}{}
|
||||
err = decoder.Decode(&authenticatorsMap)
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fields := "("
|
||||
@@ -66,7 +66,7 @@ func (p *provider) AddAuthenticator(ctx context.Context, authenticators *models.
|
||||
query := fmt.Sprintf("INSERT INTO %s %s VALUES %s IF NOT EXISTS", KeySpace+"."+models.Collections.Authenticators, fields, values)
|
||||
err = p.db.Query(query).Exec()
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return authenticators, nil
|
||||
@@ -77,7 +77,7 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode
|
||||
|
||||
bytes, err := json.Marshal(authenticators)
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
|
||||
decoder := json.NewDecoder(strings.NewReader(string(bytes)))
|
||||
@@ -85,7 +85,7 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode
|
||||
authenticatorsMap := map[string]interface{}{}
|
||||
err = decoder.Decode(&authenticatorsMap)
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updateFields := ""
|
||||
@@ -116,7 +116,7 @@ func (p *provider) UpdateAuthenticator(ctx context.Context, authenticators *mode
|
||||
query := fmt.Sprintf("UPDATE %s SET %s WHERE id = '%s'", KeySpace+"."+models.Collections.Authenticators, updateFields, authenticators.ID)
|
||||
err = p.db.Query(query).Exec()
|
||||
if err != nil {
|
||||
return authenticators, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return authenticators, nil
|
||||
|
@@ -20,7 +20,7 @@ func (p *provider) AddEnv(ctx context.Context, env *models.Env) (*models.Env, er
|
||||
insertEnvQuery := fmt.Sprintf("INSERT INTO %s (id, env, hash, created_at, updated_at) VALUES ('%s', '%s', '%s', %d, %d)", KeySpace+"."+models.Collections.Env, env.ID, env.EnvData, env.Hash, env.CreatedAt, env.UpdatedAt)
|
||||
err := p.db.Query(insertEnvQuery).Exec()
|
||||
if err != nil {
|
||||
return env, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return env, nil
|
||||
@@ -32,7 +32,7 @@ func (p *provider) UpdateEnv(ctx context.Context, env *models.Env) (*models.Env,
|
||||
updateEnvQuery := fmt.Sprintf("UPDATE %s SET env = '%s', updated_at = %d WHERE id = '%s'", KeySpace+"."+models.Collections.Env, env.EnvData, env.UpdatedAt, env.ID)
|
||||
err := p.db.Query(updateEnvQuery).Exec()
|
||||
if err != nil {
|
||||
return env, err
|
||||
return nil, err
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
|
||||
if user.Roles == "" {
|
||||
defaultRoles, err := memorystore.Provider.GetStringStoreEnvVariable(constants.EnvKeyDefaultRoles)
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
user.Roles = defaultRoles
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
|
||||
|
||||
bytes, err := json.Marshal(user)
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
|
||||
@@ -55,7 +55,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
|
||||
userMap := map[string]interface{}{}
|
||||
err = decoder.Decode(&userMap)
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fields := "("
|
||||
@@ -84,7 +84,7 @@ func (p *provider) AddUser(ctx context.Context, user *models.User) (*models.User
|
||||
err = p.db.Query(query).Exec()
|
||||
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return user, nil
|
||||
@@ -96,7 +96,7 @@ func (p *provider) UpdateUser(ctx context.Context, user *models.User) (*models.U
|
||||
|
||||
bytes, err := json.Marshal(user)
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
// use decoder instead of json.Unmarshall, because it converts int64 -> float64 after unmarshalling
|
||||
decoder := json.NewDecoder(strings.NewReader(string(bytes)))
|
||||
@@ -104,7 +104,7 @@ func (p *provider) UpdateUser(ctx context.Context, user *models.User) (*models.U
|
||||
userMap := map[string]interface{}{}
|
||||
err = decoder.Decode(&userMap)
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updateFields := ""
|
||||
@@ -135,7 +135,7 @@ func (p *provider) UpdateUser(ctx context.Context, user *models.User) (*models.U
|
||||
query := fmt.Sprintf("UPDATE %s SET %s WHERE id = '%s'", KeySpace+"."+models.Collections.User, updateFields, user.ID)
|
||||
err = p.db.Query(query).Exec()
|
||||
if err != nil {
|
||||
return user, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return user, nil
|
||||
|
@@ -23,7 +23,7 @@ func (p *provider) AddVerificationRequest(ctx context.Context, verificationReque
|
||||
query := fmt.Sprintf("INSERT INTO %s (id, jwt_token, identifier, expires_at, email, nonce, redirect_uri, created_at, updated_at) VALUES ('%s', '%s', '%s', %d, '%s', '%s', '%s', %d, %d)", KeySpace+"."+models.Collections.VerificationRequest, verificationRequest.ID, verificationRequest.Token, verificationRequest.Identifier, verificationRequest.ExpiresAt, verificationRequest.Email, verificationRequest.Nonce, verificationRequest.RedirectURI, verificationRequest.CreatedAt, verificationRequest.UpdatedAt)
|
||||
err := p.db.Query(query).Exec()
|
||||
if err != nil {
|
||||
return verificationRequest, err
|
||||
return nil, err
|
||||
}
|
||||
return verificationRequest, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user