Skip to content

Commit 2280b49

Browse files
committed
fix case sensitivity
1 parent 06cbfd1 commit 2280b49

File tree

14 files changed

+44
-46
lines changed

14 files changed

+44
-46
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2859,7 +2859,7 @@ func (q *querier) InsertWorkspaceResourceMetadata(ctx context.Context, arg datab
28592859
return q.db.InsertWorkspaceResourceMetadata(ctx, arg)
28602860
}
28612861

2862-
func (q *querier) ListProvisionerKeysByOrganization(ctx context.Context, organizationID uuid.UUID) ([]database.ListProvisionerKeysByOrganizationRow, error) {
2862+
func (q *querier) ListProvisionerKeysByOrganization(ctx context.Context, organizationID uuid.UUID) ([]database.ProvisionerKey, error) {
28632863
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.ListProvisionerKeysByOrganization)(ctx, organizationID)
28642864
}
28652865

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,7 @@ func (s *MethodTestSuite) TestProvisionerKeys() {
18351835
s.Run("ListProvisionerKeysByOrganization", s.Subtest(func(db database.Store, check *expects) {
18361836
org := dbgen.Organization(s.T(), db, database.Organization{})
18371837
pk := dbgen.ProvisionerKey(s.T(), db, database.ProvisionerKey{OrganizationID: org.ID})
1838-
pks := []database.ListProvisionerKeysByOrganizationRow{
1838+
pks := []database.ProvisionerKey{
18391839
{
18401840
ID: pk.ID,
18411841
CreatedAt: pk.CreatedAt,

coderd/database/dbmem/dbmem.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ func (inTxMutex) RLock() {}
124124
func (inTxMutex) Unlock() {}
125125
func (inTxMutex) RUnlock() {}
126126

127+
// newUniqueContraintError copies the base unique constraint error and sets the constraint to the provided value.
128+
func newUniqueContraintError(uc database.UniqueConstraint) *pq.Error {
129+
newErr := *errUniqueConstraint
130+
newErr.Constraint = string(uc)
131+
132+
return &newErr
133+
}
134+
127135
// FakeQuerier replicates database functionality to enable quick testing. It's an exported type so that our test code
128136
// can do type checks.
129137
type FakeQuerier struct {
@@ -3228,7 +3236,7 @@ func (q *FakeQuerier) GetProvisionerKeyByName(_ context.Context, arg database.Ge
32283236
defer q.mutex.RUnlock()
32293237

32303238
for _, key := range q.provisionerKeys {
3231-
if key.Name == arg.Name && key.OrganizationID == arg.OrganizationID {
3239+
if strings.ToLower(key.Name) == strings.ToLower(arg.Name) && key.OrganizationID == arg.OrganizationID {
32323240
return key, nil
32333241
}
32343242
}
@@ -6544,7 +6552,7 @@ func (q *FakeQuerier) InsertProvisionerKey(_ context.Context, arg database.Inser
65446552
defer q.mutex.Unlock()
65456553

65466554
newErr := *errUniqueConstraint
6547-
newErr.Constraint = string(database.UniqueProvisionerKeysOrganizationIDNameKey)
6555+
newErr.Constraint = string(database.UniqueProvisionerKeysOrganizationIDNameIndex)
65486556
for _, key := range q.provisionerKeys {
65496557
if key.ID == arg.ID || (key.OrganizationID == arg.OrganizationID && key.Name == arg.Name) {
65506558
return database.ProvisionerKey{}, &newErr
@@ -6556,7 +6564,7 @@ func (q *FakeQuerier) InsertProvisionerKey(_ context.Context, arg database.Inser
65566564
ID: arg.ID,
65576565
CreatedAt: arg.CreatedAt,
65586566
OrganizationID: arg.OrganizationID,
6559-
Name: arg.Name,
6567+
Name: strings.ToLower(arg.Name),
65606568
HashedSecret: arg.HashedSecret,
65616569
}
65626570
q.provisionerKeys = append(q.provisionerKeys, provisionerKey)
@@ -7241,18 +7249,19 @@ func (q *FakeQuerier) InsertWorkspaceResourceMetadata(_ context.Context, arg dat
72417249
return metadata, nil
72427250
}
72437251

7244-
func (q *FakeQuerier) ListProvisionerKeysByOrganization(_ context.Context, organizationID uuid.UUID) ([]database.ListProvisionerKeysByOrganizationRow, error) {
7252+
func (q *FakeQuerier) ListProvisionerKeysByOrganization(_ context.Context, organizationID uuid.UUID) ([]database.ProvisionerKey, error) {
72457253
q.mutex.RLock()
72467254
defer q.mutex.RUnlock()
72477255

7248-
keys := make([]database.ListProvisionerKeysByOrganizationRow, 0)
7256+
keys := make([]database.ProvisionerKey, 0)
72497257
for _, key := range q.provisionerKeys {
72507258
if key.OrganizationID == organizationID {
7251-
keys = append(keys, database.ListProvisionerKeysByOrganizationRow{
7259+
keys = append(keys, database.ProvisionerKey{
72527260
ID: key.ID,
72537261
CreatedAt: key.CreatedAt,
72547262
OrganizationID: key.OrganizationID,
72557263
Name: key.Name,
7264+
HashedSecret: key.HashedSecret,
72567265
})
72577266
}
72587267
}

coderd/database/dbmetrics/dbmetrics.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmock/dbmock.go

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

coderd/database/dump.sql

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

coderd/database/migrations/000226_provisioner_keys.up.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE TABLE provisioner_keys (
33
created_at timestamptz NOT NULL,
44
organization_id uuid NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
55
name varchar(64) NOT NULL,
6-
hashed_secret bytea NOT NULL,
6+
hashed_secret bytea NOT NULL
77
);
88

9-
CREATE INDEX provisioner_keys_organization_id_name_idx ON provisioner_keys (organization_id, name);
9+
CREATE UNIQUE INDEX provisioner_keys_organization_id_name_idx ON provisioner_keys (organization_id, name);

coderd/database/querier.go

Lines changed: 1 addition & 1 deletion
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: 9 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/provisionerkeys.sql

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ INSERT INTO
88
hashed_secret
99
)
1010
VALUES
11-
($1, $2, $3, lower($4), $5) RETURNING *;
11+
($1, $2, $3, lower(@name), $4) RETURNING *;
1212

1313
-- name: GetProvisionerKeyByID :one
1414
SELECT
@@ -26,14 +26,11 @@ FROM
2626
WHERE
2727
organization_id = $1
2828
AND
29-
name = $2;
29+
name = lower(@name);
3030

3131
-- name: ListProvisionerKeysByOrganization :many
3232
SELECT
33-
id,
34-
created_at,
35-
organization_id,
36-
name
33+
*
3734
FROM
3835
provisioner_keys
3936
WHERE

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy