-
-
Notifications
You must be signed in to change notification settings - Fork 635
sa: getAuthorizationStatuses checks results #8726
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
Open
jsha
wants to merge
3
commits into
main
Choose a base branch
from
checkvalidities
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -451,11 +451,16 @@ func (ssa *SQLStorageAuthority) DeactivateAuthorization2(ctx context.Context, re | |
| return &emptypb.Empty{}, nil | ||
| } | ||
|
|
||
| // NewOrderAndAuthzs adds the given authorizations to the database, adds their | ||
| // autogenerated IDs to the given order, and then adds the order to the db. | ||
| // This is done inside a single transaction to prevent situations where new | ||
| // authorizations are created, but then their corresponding order is never | ||
| // created, leading to "invisible" pending authorizations. | ||
| // NewOrderAndAuthzs creates an order in the database. | ||
| // | ||
| // The order will include reused authorization IDs from the V2Authorizations slice | ||
| // and newly created authorizations based on NewAuthzs slice. Either slice may be | ||
| // empty but not both. Duplicate authorization IDs in V2Authorizations will error. | ||
| // | ||
| // Creation of new authorizations is done inside a transaction along with creation | ||
| // of the order to prevent situations where new authorizations are created, but then | ||
| // their corresponding order is never created, leading to "invisible" pending | ||
| // authorizations. | ||
| func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb.NewOrderAndAuthzsRequest) (*corepb.Order, error) { | ||
| if req.NewOrder == nil { | ||
| return nil, errIncompleteRequest | ||
|
|
@@ -491,6 +496,10 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb | |
| // Combine the already-existing and newly-created authzs. | ||
| allAuthzIds := append(req.NewOrder.V2Authorizations, newAuthzIDs...) | ||
|
|
||
| if containsDuplicates(allAuthzIds) { | ||
| return nil, errors.New("cannot add duplicate authorizations to order") | ||
| } | ||
|
|
||
| // Second, insert the new order. | ||
| created := ssa.clk.Now() | ||
| encodedAuthzs, err := proto.Marshal(&sapb.Authzs{ | ||
|
|
@@ -578,6 +587,17 @@ func (ssa *SQLStorageAuthority) NewOrderAndAuthzs(ctx context.Context, req *sapb | |
| return order, nil | ||
| } | ||
|
|
||
| func containsDuplicates(ids []int64) bool { | ||
| seen := make(map[int64]bool, len(ids)) | ||
| for _, id := range ids { | ||
| if seen[id] { | ||
| return true | ||
| } | ||
| seen[id] = true | ||
| } | ||
| return false | ||
| } | ||
|
Comment on lines
+590
to
+599
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could do the same thing with slices.Contains(). |
||
|
|
||
| // SetOrderProcessing updates an order from pending status to processing | ||
| // status by updating the `beganProcessing` field of the corresponding | ||
| // Order table row in the DB. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.