-
Notifications
You must be signed in to change notification settings - Fork 50
M2 - remaining backend items - follow up - sanctioned date support #5152
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5d711a2
Add sanctioned date to EasyCLA DDB table - set when flagged state det…
lukaszgryglicki 2fda6ab
Add sanctioned date to EasyCLA DDB table - set when flagged state det…
lukaszgryglicki d6bffbd
Add sanctioned date to EasyCLA DDB table - set when flagged state det…
lukaszgryglicki 9ce8dbe
Add sanctioned date to EasyCLA DDB table - set when flagged state det…
lukaszgryglicki 997d4d1
Add sanctioned date to EasyCLA DDB table - set when flagged state det…
lukaszgryglicki 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
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 |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // Copyright The Linux Foundation and each contributor to CommunityBridge. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package company | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestBuildSanctionUpdate(t *testing.T) { | ||
| const now = "2026-08-20T10:11:12Z" | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| sanctioned bool | ||
| origin string | ||
| expression string | ||
| condition string | ||
| stampedDate bool | ||
| }{ | ||
| { | ||
| name: "sss flags the company", | ||
| sanctioned: true, | ||
| origin: sanctionOriginSSS, | ||
| expression: "SET #S = :s, #M = :m, #D = :d, #O = :o", | ||
| condition: "attribute_not_exists(#S) OR #S = :false OR #O = :o", | ||
| stampedDate: true, | ||
| }, | ||
| { | ||
| name: "sss clears the company", | ||
| sanctioned: false, | ||
| origin: sanctionOriginSSS, | ||
| expression: "SET #S = :s, #M = :m, #O = :o", | ||
| }, | ||
| { | ||
| name: "admin flags the company", | ||
| sanctioned: true, | ||
| origin: "", | ||
| expression: "SET #S = :s, #M = :m, #D = :d REMOVE #O", | ||
| stampedDate: true, | ||
| }, | ||
| { | ||
| name: "admin clears the company", | ||
| sanctioned: false, | ||
| origin: "", | ||
| expression: "SET #S = :s, #M = :m REMOVE #O", | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| update := buildSanctionUpdate(tc.sanctioned, tc.origin, now) | ||
|
|
||
| assert.Equal(t, tc.expression, update.expression) | ||
| if tc.condition == "" { | ||
| assert.Nil(t, update.condition, "only an SSS-set flag is conditional") | ||
| } else { | ||
| require.NotNil(t, update.condition) | ||
| assert.Equal(t, tc.condition, *update.condition, "the manual/admin block must stay protected") | ||
| } | ||
|
|
||
| if tc.stampedDate { | ||
| require.Contains(t, update.names, "#D") | ||
| assert.Equal(t, "sanctioned_date", *update.names["#D"]) | ||
| require.Contains(t, update.values, ":d") | ||
| assert.Equal(t, now, *update.values[":d"].S, "the flag and the date are stamped with the same time") | ||
| } else { | ||
| assert.NotContains(t, update.names, "#D", "clearing the flag leaves the stored date alone") | ||
| assert.NotContains(t, update.values, ":d") | ||
| } | ||
|
|
||
| assert.Equal(t, tc.sanctioned, *update.values[":s"].BOOL) | ||
| assert.Equal(t, now, *update.values[":m"].S) | ||
|
|
||
| // Every declared name and value has to be referenced, or DynamoDB rejects the update. | ||
| for name := range update.names { | ||
| assert.Contains(t, update.expression+condition(update), name) | ||
| } | ||
| for value := range update.values { | ||
| assert.Contains(t, update.expression+condition(update), value) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func condition(update sanctionUpdate) string { | ||
| if update.condition == nil { | ||
| return "" | ||
| } | ||
| return " " + *update.condition | ||
| } |
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
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.
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.