-
Notifications
You must be signed in to change notification settings - Fork 360
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
8224 report required permissions when authorization fails #8314
Merged
ItamarYuran
merged 18 commits into
master
from
8224-report-required-permissions-when-authorization-fails
Nov 12, 2024
+188
−16
Merged
Changes from 17 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f1c6393
deny works
ItamarYuran 88175ae
reporting missing permissions
ItamarYuran 2242218
works
ItamarYuran b1f9e3a
fixed errors
ItamarYuran 11aa10a
fixed esti
ItamarYuran ee2986a
enhanced, very enhanced
ItamarYuran d04f675
crossing fingaz
ItamarYuran e883b3c
using string.contains
ItamarYuran 5da4f66
with changes no tests
ItamarYuran 54dc6aa
service
ItamarYuran 743f818
yesh tests
ItamarYuran 4a054c6
basic changes
ItamarYuran 803d4a3
minor changes
ItamarYuran 758d910
simpler, returning first missing
ItamarYuran 7b304cc
simpler, no mock
ItamarYuran 7992c4b
final tunings
ItamarYuran 060083f
no empty lines
ItamarYuran 2c50f4a
now using parm
ItamarYuran 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 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 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"context" | ||
"net/http" | ||
"slices" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -234,7 +235,7 @@ func TestCreateRepo_Unauthorized(t *testing.T) { | |
}) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp.JSON401) | ||
if resp.JSON401.Message != auth.ErrInsufficientPermissions.Error() { | ||
if !strings.Contains(resp.JSON401.Message, auth.ErrInsufficientPermissions.Error()) { | ||
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. Can we test here (and below) that we got an expected value? Obviously doing so makes sense only after we finalize the message contents. So it is fine to open an issue to improve these checks in this test file. |
||
t.Fatalf("expected error message %q, got %q", auth.ErrInsufficientPermissions.Error(), resp.JSON401.Message) | ||
} | ||
} | ||
|
@@ -255,15 +256,15 @@ func TestRepoMetadata_Unauthorized(t *testing.T) { | |
}) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp.JSON401) | ||
if resp.JSON401.Message != auth.ErrInsufficientPermissions.Error() { | ||
if !strings.Contains(resp.JSON401.Message, auth.ErrInsufficientPermissions.Error()) { | ||
t.Errorf("expected error message %q, got %q", auth.ErrInsufficientPermissions.Error(), resp.JSON401.Message) | ||
} | ||
}) | ||
t.Run("delete", func(t *testing.T) { | ||
resp, err := clt.DeleteRepositoryMetadataWithResponse(ctx, repo, apigen.DeleteRepositoryMetadataJSONRequestBody{Keys: []string{"foo"}}) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp.JSON401) | ||
if resp.JSON401.Message != auth.ErrInsufficientPermissions.Error() { | ||
if !strings.Contains(resp.JSON401.Message, auth.ErrInsufficientPermissions.Error()) { | ||
t.Errorf("expected error message %q, got %q", auth.ErrInsufficientPermissions.Error(), resp.JSON401.Message) | ||
} | ||
}) | ||
|
@@ -272,7 +273,7 @@ func TestRepoMetadata_Unauthorized(t *testing.T) { | |
resp, err := clt.GetRepositoryMetadataWithResponse(ctx, repo) | ||
require.NoError(t, err) | ||
require.NotNil(t, resp.JSON401) | ||
if resp.JSON401.Message != auth.ErrInsufficientPermissions.Error() { | ||
if !strings.Contains(resp.JSON401.Message, auth.ErrInsufficientPermissions.Error()) { | ||
t.Errorf("expected error message %q, got %q", auth.ErrInsufficientPermissions.Error(), resp.JSON401.Message) | ||
} | ||
}) | ||
|
This file contains 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 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going back to prev question - what are you doing with
perm
afterauth.CheckPermissions
? I don't see it being used.