Default active to TRUE for access entries
Drivers that cannot determine account status leave Active nil. Rather than surfacing NULL in the database, treat an absent signal as active (the account appeared in the source listing). - Migration: NOT NULL DEFAULT TRUE on the active column - Insert/upsert SQL: COALESCE(@active, TRUE) on write - Fix new(true) in test (not valid Go; use &activeTrue) Signed-off-by: Bryan Frimin <bryan@probo.com>
This commit is contained in:
@@ -228,7 +228,7 @@ VALUES (
|
||||
@mfa_status,
|
||||
@auth_method,
|
||||
@account_type,
|
||||
@active,
|
||||
COALESCE(@active, TRUE),
|
||||
@last_login,
|
||||
@account_created_at,
|
||||
@external_id,
|
||||
@@ -665,7 +665,7 @@ INSERT INTO access_entries (
|
||||
@mfa_status,
|
||||
@auth_method,
|
||||
@account_type,
|
||||
@active,
|
||||
COALESCE(@active, TRUE),
|
||||
@last_login,
|
||||
@account_created_at,
|
||||
@external_id,
|
||||
|
||||
@@ -441,6 +441,7 @@ func TestAccessEntry_Upsert_InsertsActiveAccount(t *testing.T) {
|
||||
tenantID := fx.scope.GetTenantID()
|
||||
t0 := time.Now().UTC().Truncate(time.Microsecond)
|
||||
|
||||
activeTrue := true
|
||||
entryID := gid.New(tenantID, coredata.AccessEntryEntityType)
|
||||
entry := &coredata.AccessEntry{
|
||||
ID: entryID,
|
||||
@@ -453,7 +454,7 @@ func TestAccessEntry_Upsert_InsertsActiveAccount(t *testing.T) {
|
||||
MFAStatus: coredata.MFAStatusUnknown,
|
||||
AuthMethod: coredata.AccessEntryAuthMethodUnknown,
|
||||
AccountType: coredata.AccessEntryAccountTypeUser,
|
||||
Active: new(true),
|
||||
Active: &activeTrue,
|
||||
ExternalID: "ext-active",
|
||||
AccountKey: fx.accountKey,
|
||||
IncrementalTag: coredata.AccessEntryIncrementalTagNew,
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
-- PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
ALTER TABLE access_entries
|
||||
ADD COLUMN active BOOLEAN;
|
||||
ADD COLUMN active BOOLEAN NOT NULL DEFAULT TRUE;
|
||||
|
||||
Reference in New Issue
Block a user