Repository navigation
[CXH-2368] - Fix license grant rewriting the site role of a user who already holds the tier #55
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
sergiocorral-conductorone
wants to merge
15
commits into
main
Choose a base branch
from
sergiocorral/cxh-2368-baton-tableau-fix-license-grant-rewriting-the-site-role-of-a
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.
+1,027
−30
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
33b2565
[CXH-2368] - Fix license grant rewriting the site role of a user who …
sergiocorral-conductorone d721c26
[CXH-2368] - Address review feedback on license grant/revoke
sergiocorral-conductorone a9a7016
[CXH-2368] - Reword comments and docs to describe current behavior
sergiocorral-conductorone d3273cc
[CXH-2368] - Bypass response cache in GetUser and cover stale-read cases
sergiocorral-conductorone 06ef62d
[CXH-2368] - Reword ServerAdministrator notes to match Tableau docs
sergiocorral-conductorone 094978f
[CXH-2368] - Drop duplicate warn log on admin license grant refusal
sergiocorral-conductorone 491f8ad
fix: treat Unlicensed license revoke as an annotated no-op
sergiocorral-conductorone 7871521
docs: clarify tier-aware license provisioning and floor-role no-op
sergiocorral-conductorone 2b4009a
[CXH-2368] - Declare license tiers as one exclusion group and tighten…
sergiocorral-conductorone 42f1601
[CXH-2368] - Consolidate license tests in license_test.go
sergiocorral-conductorone 9977f65
[CXH-2368] - Address review: wrap NotFound, simplify replaced-grant c…
sergiocorral-conductorone 94370d8
Merge main into sergiocorral/cxh-2368-baton-tableau-fix-license-grant…
sergiocorral-conductorone e04a03f
[CXH-2368] - Return InvalidArgument for an unknown license tier
sergiocorral-conductorone 9955e0d
Merge origin/main into sergiocorral/cxh-2368-baton-tableau-fix-licens…
sergiocorral-conductorone fad2cab
[CXH-2368] - Return the new grant from license Grant (V2 signature)
sergiocorral-conductorone 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
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,71 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/conductorone/baton-sdk/pkg/uhttp" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| const testSiteId = "site-1" | ||
|
|
||
| // newTestClient builds a Client wired directly to srv, bypassing New's | ||
| // Login/auth-signin flow so tests only exercise the endpoint under test. | ||
| func newTestClient(t *testing.T, srv *httptest.Server) *Client { | ||
| t.Helper() | ||
|
|
||
| base, err := uhttp.NewBaseHttpClientWithContext(context.Background(), srv.Client()) | ||
| require.NoError(t, err) | ||
|
|
||
| return &Client{ | ||
| httpClient: base, | ||
| baseUrl: srv.URL, | ||
| authToken: "test-token", | ||
| siteId: testSiteId, | ||
| } | ||
| } | ||
|
|
||
| func TestGetUser_Found(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| wantPath := "/sites/" + testSiteId + "/users/user-1" | ||
|
|
||
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if r.URL.Path != wantPath { | ||
| w.WriteHeader(http.StatusNotFound) | ||
| return | ||
| } | ||
| w.Header().Set("Content-Type", "application/json") | ||
| _, _ = w.Write([]byte(`{"user":{"id":"user-1","email":"user1@example.com","siteRole":"SiteAdministratorCreator"}}`)) | ||
| })) | ||
| t.Cleanup(srv.Close) | ||
|
|
||
| c := newTestClient(t, srv) | ||
|
|
||
| user, _, err := c.GetUser(context.Background(), "user-1") | ||
| require.NoError(t, err) | ||
| require.NotNil(t, user) | ||
| require.Equal(t, "user-1", user.ID) | ||
| require.Equal(t, "SiteAdministratorCreator", user.SiteRole) | ||
| } | ||
|
|
||
| func TestGetUser_NotFound(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| w.Header().Set("Content-Type", "application/json") | ||
| w.WriteHeader(http.StatusNotFound) | ||
| _, _ = w.Write([]byte(`{"error":{"summary":"Not Found","detail":"User not found","code":"0x1"}}`)) | ||
| })) | ||
| t.Cleanup(srv.Close) | ||
|
|
||
| c := newTestClient(t, srv) | ||
|
|
||
| user, _, err := c.GetUser(context.Background(), "missing-user") | ||
| require.Error(t, err) | ||
| require.Nil(t, user) | ||
| require.True(t, IsNotFoundError(err), "expected IsNotFoundError(err) to be true, got err: %v", err) | ||
| } |
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.