Don't rely on token for scopes collection actions (#210)
Don't rely on token for scopes collection actions This requires `scope_id` to be passed (via query param) for actions on the scopes collection; that is, listing or creating. However, it removes the dependency on using the token for the scope of the command. For actions on a specific scope, we use the given ID to determine the scope we should be operating at, doing a lookup if necessary. Existing tests have been updated. Of particular note, the CORS test was already operating on the scopes collection so served as a good test to ensure that from an API level the scope_id parameter was being parsed and passed through (the tests fail without adding that query parameter in).
This commit is contained in:
1 parent
2bbc1163c4
commit
e8325a9f59
17 files changed
+372
-243
No files matched your search
@@ -65,7 +65,6 @@ func TestAuthenticate(t *testing.T) {
|
||||
{
|
||||
name: "basic",
|
||||
request: &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
AuthMethodId: amId,
|
||||
TokenType: "token",
|
||||
Credentials: func() *structpb.Struct {
|
||||
@@ -83,7 +82,6 @@ func TestAuthenticate(t *testing.T) {
|
||||
{
|
||||
name: "no-token-type",
|
||||
request: &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
AuthMethodId: amId,
|
||||
Credentials: func() *structpb.Struct {
|
||||
creds := map[string]*structpb.Value{
|
||||
@@ -100,7 +98,6 @@ func TestAuthenticate(t *testing.T) {
|
||||
{
|
||||
name: "bad-token-type",
|
||||
request: &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
AuthMethodId: amId,
|
||||
TokenType: "email",
|
||||
Credentials: func() *structpb.Struct {
|
||||
@@ -116,7 +113,6 @@ func TestAuthenticate(t *testing.T) {
|
||||
{
|
||||
name: "no-authmethod",
|
||||
request: &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
Credentials: func() *structpb.Struct {
|
||||
creds := map[string]*structpb.Value{
|
||||
"name": {Kind: &structpb.Value_StringValue{StringValue: "admin"}},
|
||||
@@ -130,7 +126,6 @@ func TestAuthenticate(t *testing.T) {
|
||||
{
|
||||
name: "wrong-username-password",
|
||||
request: &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
AuthMethodId: amId,
|
||||
TokenType: "token",
|
||||
Credentials: func() *structpb.Struct {
|
||||
@@ -214,7 +209,6 @@ func TestAuthenticate_AuthAccountConnectedToIamUser(t *testing.T) {
|
||||
s, err := NewService(iamRepoFn, authTokenRepoFn)
|
||||
require.NoError(err)
|
||||
resp, err := s.Authenticate(context.Background(), &pbs.AuthenticateRequest{
|
||||
ScopeId: o.GetPublicId(),
|
||||
AuthMethodId: amId,
|
||||
Credentials: func() *structpb.Struct {
|
||||
creds := map[string]*structpb.Value{
|
||||
|
||||
Reference in new issue
Block a user