Skip to content

Commit e41c103

Browse files
committed
more rewriting
1 parent c1b9871 commit e41c103

File tree

11 files changed

+397
-174
lines changed

11 files changed

+397
-174
lines changed

coderd/audit/diff_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ func TestDiff(t *testing.T) {
158158
UpdatedAt: time.Now(),
159159
Status: database.UserStatusActive,
160160
RBACRoles: []string{"omega admin"},
161-
LoginType: database.LoginTypePassword,
162-
LinkedID: "foobar",
163161
},
164162
exp: audit.Map{
165163
"id": uuid.UUID{1}.String(),
@@ -168,8 +166,6 @@ func TestDiff(t *testing.T) {
168166
"hashed_password": ([]byte)(nil),
169167
"status": database.UserStatusActive,
170168
"rbac_roles": []string{"omega admin"},
171-
"login_type": database.LoginTypePassword,
172-
"linked_id": "foobar",
173169
},
174170
},
175171
})

coderd/database/databasefake/databasefake.go

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,20 +1453,16 @@ func (q *fakeQuerier) InsertAPIKey(_ context.Context, arg database.InsertAPIKeyP
14531453

14541454
//nolint:gosimple
14551455
key := database.APIKey{
1456-
ID: arg.ID,
1457-
LifetimeSeconds: arg.LifetimeSeconds,
1458-
HashedSecret: arg.HashedSecret,
1459-
IPAddress: arg.IPAddress,
1460-
UserID: arg.UserID,
1461-
ExpiresAt: arg.ExpiresAt,
1462-
CreatedAt: arg.CreatedAt,
1463-
UpdatedAt: arg.UpdatedAt,
1464-
LastUsed: arg.LastUsed,
1465-
LoginType: arg.LoginType,
1466-
OAuthAccessToken: arg.OAuthAccessToken,
1467-
OAuthRefreshToken: arg.OAuthRefreshToken,
1468-
OAuthIDToken: arg.OAuthIDToken,
1469-
OAuthExpiry: arg.OAuthExpiry,
1456+
ID: arg.ID,
1457+
LifetimeSeconds: arg.LifetimeSeconds,
1458+
HashedSecret: arg.HashedSecret,
1459+
IPAddress: arg.IPAddress,
1460+
UserID: arg.UserID,
1461+
ExpiresAt: arg.ExpiresAt,
1462+
CreatedAt: arg.CreatedAt,
1463+
UpdatedAt: arg.UpdatedAt,
1464+
LastUsed: arg.LastUsed,
1465+
LoginType: arg.LoginType,
14701466
}
14711467
q.apiKeys = append(q.apiKeys, key)
14721468
return key, nil
@@ -1743,8 +1739,6 @@ func (q *fakeQuerier) InsertUser(_ context.Context, arg database.InsertUserParam
17431739
Username: arg.Username,
17441740
Status: database.UserStatusActive,
17451741
RBACRoles: arg.RBACRoles,
1746-
LoginType: arg.LoginType,
1747-
LinkedID: arg.LinkedID,
17481742
}
17491743
q.users = append(q.users, user)
17501744
return user, nil
@@ -1900,9 +1894,6 @@ func (q *fakeQuerier) UpdateAPIKeyByID(_ context.Context, arg database.UpdateAPI
19001894
apiKey.LastUsed = arg.LastUsed
19011895
apiKey.ExpiresAt = arg.ExpiresAt
19021896
apiKey.IPAddress = arg.IPAddress
1903-
apiKey.OAuthAccessToken = arg.OAuthAccessToken
1904-
apiKey.OAuthRefreshToken = arg.OAuthRefreshToken
1905-
apiKey.OAuthExpiry = arg.OAuthExpiry
19061897
q.apiKeys[index] = apiKey
19071898
return nil
19081899
}
@@ -2261,30 +2252,3 @@ func (q *fakeQuerier) GetDeploymentID(_ context.Context) (string, error) {
22612252

22622253
return q.deploymentID, nil
22632254
}
2264-
2265-
func (q *fakeQuerier) UpdateUserLinkedID(_ context.Context, arg database.UpdateUserLinkedIDParams) (database.User, error) {
2266-
q.mutex.Lock()
2267-
defer q.mutex.Unlock()
2268-
2269-
for index, user := range q.users {
2270-
if user.ID != arg.ID {
2271-
continue
2272-
}
2273-
user.LinkedID = arg.LinkedID
2274-
q.users[index] = user
2275-
return user, nil
2276-
}
2277-
return database.User{}, sql.ErrNoRows
2278-
}
2279-
2280-
func (q *fakeQuerier) GetUserByLinkedID(_ context.Context, linkedID string) (database.User, error) {
2281-
q.mutex.RLock()
2282-
defer q.mutex.RUnlock()
2283-
2284-
for _, user := range q.users {
2285-
if user.LinkedID == linkedID {
2286-
return user, nil
2287-
}
2288-
}
2289-
return database.User{}, sql.ErrNoRows
2290-
}

coderd/database/db_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ func TestNestedInTx(t *testing.T) {
3737
CreatedAt: database.Now(),
3838
UpdatedAt: database.Now(),
3939
RBACRoles: []string{},
40-
LoginType: database.LoginTypePassword,
41-
LinkedID: uuid.NewString(),
4240
})
4341
return err
4442
})

coderd/database/querier.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 179 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/apikeys.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ INSERT INTO
2222
last_used,
2323
expires_at,
2424
created_at,
25-
updated_at
25+
updated_at,
26+
login_type
2627
)
2728
VALUES
2829
(@id,
@@ -31,7 +32,7 @@ VALUES
3132
WHEN 0 THEN 86400
3233
ELSE @lifetime_seconds::bigint
3334
END
34-
, @hashed_secret, @ip_address, @user_id, @last_used, @expires_at, @created_at, @updated_at) RETURNING *;
35+
, @hashed_secret, @ip_address, @user_id, @last_used, @expires_at, @created_at, @updated_at, @login_type) RETURNING *;
3536

3637
-- name: UpdateAPIKeyByID :exec
3738
UPDATE

0 commit comments

Comments
 (0)