Repository navigation
Let named operators assign the agent work, when the operator opts them in #847
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
11 commits
Select commit
Hold shift + click to select a range
f5ec4d1
Let named operators assign the agent work, when the operator opts the…
jeremy 06de5f2
Name the assignment opt-in where setup's command is built, and say wh…
jeremy d10b9ee
Carry the assignment opt-in over to operators named beside project trust
jeremy e1a6210
Hold the opt-in to someone besides the operator, and say it covers ev…
jeremy ea8bdc5
Turn the opt-in off when a run names a new list without restating it
jeremy 738dece
Keep the opt-in when a run's list names nobody new
jeremy 456496a
Say when an assignment reaches the agent, and that the opt-in needs s…
jeremy dae262e
Drop the opt-in when the new operator is the only person it covered
jeremy 106a2b8
Refuse an opt-in asked for in a run that leaves it nobody, and drop o…
jeremy 57c36eb
Let the opt-in ride with --allow, with no history to compare
jeremy 1f5ed62
Say the opt-in flag covers the kept allowlist too
jeremy 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
Some comments aren't visible on the classic Files Changed page.
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,88 @@ | ||
| package admission | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/basecamp/basecamp-sdk/go/pkg/basecamp" | ||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // allow_assignments lets the people the allowlist names assign the agent work, | ||
| // as the operator does. The assigner is the feed's performer, which Basecamp | ||
| // writes and no payload carries, so naming someone here trusts them, not text | ||
| // that claims to be them. Nobody it doesn't name gains anything. | ||
| func TestNamedOperatorsMayAssignWhenOptedIn(t *testing.T) { | ||
| optedIn := func() Policy { | ||
| p := basePolicy() | ||
| p.Trust = Trust{Mode: TrustAllowlist, OperatorID: operatorID, AllowlistIDs: []int64{allowedID}, AllowAssignments: true} | ||
| return p | ||
| } | ||
| assignment := func(performer int64) Event { | ||
| return Event{ID: eventID, EventType: "card.assignment_changed", BucketID: servedProj, RecordingID: recordingID, CreatorID: performer} | ||
| } | ||
| card := func(f *fakeReads) { | ||
| f.summaries[recordingID] = summaryWith(recordingID, servedProj, "Kanban::Card", strangerID, "<div>a card</div>") | ||
| f.summaries[recordingID].Assignees = []basecamp.Person{{ID: agentID}} | ||
| f.assignments[eventID] = []int64{agentID} | ||
| } | ||
|
|
||
| t.Run("a named operator assigning the agent is admitted", func(t *testing.T) { | ||
| f := newFakeReads() | ||
| card(f) | ||
| v := decide(t, newAdmitter(t, optedIn(), f), assignment(allowedID)) | ||
| require.Equal(t, StateAdmitted, v.State, "reason %q", v.Reason) | ||
| assert.Equal(t, TriggerAssigned, v.Trigger) | ||
| assert.Equal(t, allowedID, v.RequesterID) | ||
| assert.Equal(t, 1, f.assignCalls, "and only once the events show this assignment added the agent") | ||
| }) | ||
|
|
||
| t.Run("so is one named beside project trust, and the members still are not", func(t *testing.T) { | ||
| p := optedIn() | ||
| p.Trust.Mode = TrustProject | ||
| f := newFakeReads() | ||
| card(f) | ||
| f.members[servedProj] = map[int64]bool{memberID: true} | ||
| v := decide(t, newAdmitter(t, p, f), assignment(allowedID)) | ||
| require.Equal(t, StateAdmitted, v.State, "reason %q", v.Reason) | ||
| assert.Equal(t, RoleOperator, v.Role) | ||
|
|
||
| f = newFakeReads() | ||
| card(f) | ||
| f.members[servedProj] = map[int64]bool{memberID: true} | ||
| v = decide(t, newAdmitter(t, p, f), assignment(memberID)) | ||
| assert.Equal(t, ReasonAssignmentNotOperator, v.Reason) | ||
| }) | ||
|
|
||
| t.Run("anyone else is still refused at the gate", func(t *testing.T) { | ||
| for _, performer := range []int64{strangerID, memberID} { | ||
| f := newFakeReads() | ||
| card(f) | ||
| v := decide(t, newAdmitter(t, optedIn(), f), assignment(performer)) | ||
| assert.Equal(t, StateDiscarded, v.State) | ||
| assert.Equal(t, ReasonAssignmentNotOperator, v.Reason) | ||
| assert.Zero(t, f.totalReads()) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("without the opt-in, a named operator's assignment is refused", func(t *testing.T) { | ||
| f := newFakeReads() | ||
| card(f) | ||
| p := optedIn() | ||
| p.Trust.AllowAssignments = false | ||
| v := decide(t, newAdmitter(t, p, f), assignment(allowedID)) | ||
| assert.Equal(t, ReasonAssignmentNotOperator, v.Reason) | ||
| }) | ||
|
|
||
| t.Run("an opt-in that names nobody is refused", func(t *testing.T) { | ||
| p := basePolicy() | ||
| p.Trust.AllowAssignments = true | ||
| assert.Error(t, p.Validate()) | ||
| }) | ||
|
|
||
| t.Run("and so is one that names only the operator, who needs none", func(t *testing.T) { | ||
| p := optedIn() | ||
| p.Trust.AllowlistIDs = []int64{operatorID} | ||
| assert.Error(t, p.Validate()) | ||
| }) | ||
| } |
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
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.