Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production 2024-02-06_05 #2345

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/skus/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ func areTimeLimitedV2CredsSubmitted(ctx context.Context, dbi getContext, request
select 1 from time_limited_v2_order_creds where blinded_creds->>0 = $1
) as already_submitted,
exists(
select 1 from time_limited_v2_order_creds where blinded_creds->>0 = $1 and request_id != $2
select 1 from time_limited_v2_order_creds where blinded_creds->>0 != $1 and request_id = $2
) as mismatch
`
err := dbi.GetContext(ctx, &result, query, blindedCreds[0], requestID)
Expand Down
24 changes: 23 additions & 1 deletion services/skus/datastore_noint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,31 @@ func TestAreTimeLimitedV2CredsSubmitted(t *testing.T) {

tests := []testCase{
{
name: "mismatch",
name: "already_submitted",
dbi: &mockGetContext{
getContext: func(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
*dest.(*AreTimeLimitedV2CredsSubmittedResult) = AreTimeLimitedV2CredsSubmittedResult{
AlreadySubmitted: true,
Mismatch: false,
}
return nil
},
},
given: uuid.Must(uuid.FromString("8f51f9ca-b593-4200-9bfb-91ac34748e09")),
exp: tcExpected{
noErr: true,
result: map[string]bool{
"alreadySubmitted": true,
"mismatch": false,
},
},
},
{
name: "mismatch",
dbi: &mockGetContext{
getContext: func(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
*dest.(*AreTimeLimitedV2CredsSubmittedResult) = AreTimeLimitedV2CredsSubmittedResult{
AlreadySubmitted: false,
Mismatch: true,
}
return nil
Expand All @@ -52,6 +72,7 @@ func TestAreTimeLimitedV2CredsSubmitted(t *testing.T) {
exp: tcExpected{
noErr: true,
result: map[string]bool{
"alreadySubmitted": false,
"mismatch": true,
},
},
Expand All @@ -63,6 +84,7 @@ func TestAreTimeLimitedV2CredsSubmitted(t *testing.T) {

t.Run(tc.name, func(t *testing.T) {
result, err := areTimeLimitedV2CredsSubmitted(context.TODO(), tc.dbi, tc.given, "")
should.Equal(t, tc.exp.result["alreadySubmitted"], result.AlreadySubmitted)
should.Equal(t, tc.exp.result["mismatch"], result.Mismatch)
should.Equal(t, tc.exp.noErr, err == nil)
})
Expand Down
25 changes: 22 additions & 3 deletions services/skus/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,8 @@ func (suite *PostgresTestSuite) TestAreTimeLimitedV2CredsSubmitted() {
exp exp
}

sharedId := uuid.NewV4()

tests := []testCases{
{
name: "no_creds",
Expand All @@ -694,7 +696,7 @@ func (suite *PostgresTestSuite) TestAreTimeLimitedV2CredsSubmitted() {
},
},
{
name: "already_submitted_true_and_mismatch_true",
name: "already_submitted_true_and_mismatch_false",
given: tcGiven{
reqID: uuid.NewV4(),
timeAwareCrds: TimeAwareSubIssuedCreds{
Expand All @@ -704,7 +706,24 @@ func (suite *PostgresTestSuite) TestAreTimeLimitedV2CredsSubmitted() {
blindedCreds: []string{"test-cred"},
},
exp: exp{
submittedCreds: AreTimeLimitedV2CredsSubmittedResult{AlreadySubmitted: true, Mismatch: true},
submittedCreds: AreTimeLimitedV2CredsSubmittedResult{AlreadySubmitted: true, Mismatch: false},
mustErr: func(t must.TestingT, err error, i ...interface{}) {
must.NoError(t, err)
},
},
},
{
name: "already_submitted_false_and_mismatch_true",
given: tcGiven{
reqID: sharedId,
timeAwareCrds: TimeAwareSubIssuedCreds{
RequestID: sharedId.String(),
BlindedCreds: []string{"other-cred"},
},
blindedCreds: []string{"new-cred"},
},
exp: exp{
submittedCreds: AreTimeLimitedV2CredsSubmittedResult{AlreadySubmitted: false, Mismatch: true},
mustErr: func(t must.TestingT, err error, i ...interface{}) {
must.NoError(t, err)
},
Expand Down Expand Up @@ -752,7 +771,7 @@ func (suite *PostgresTestSuite) TestAreTimeLimitedV2CredsSubmitted() {
must.NoError(t, err5)
}

actual, err := suite.storage.AreTimeLimitedV2CredsSubmitted(ctx, uuid.NewV4(), tc.given.blindedCreds...)
actual, err := suite.storage.AreTimeLimitedV2CredsSubmitted(ctx, tc.given.reqID, tc.given.blindedCreds...)
tc.exp.mustErr(t, err)

should.Equal(t, tc.exp.submittedCreds, actual)
Expand Down
Loading