mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
acl: sso auth methods RPC/API/CLI should return created or updated objects (#15410)
Currently CRUD code that operates on SSO auth methods does not return created or updated object upon creation/update. This is bad UX and inconsistent behavior compared to other ACL objects like roles, policies or tokens. This PR fixes it. Relates to #13120
This commit is contained in:
committed by
GitHub
parent
fa0afdbdd9
commit
fe1ff602f8
22
api/acl.go
22
api/acl.go
@@ -319,27 +319,29 @@ func (a *ACLAuthMethods) List(q *QueryOptions) ([]*ACLAuthMethodListStub, *Query
|
||||
}
|
||||
|
||||
// Create is used to create an ACL auth-method.
|
||||
func (a *ACLAuthMethods) Create(authMethod *ACLAuthMethod, w *WriteOptions) (*WriteMeta, error) {
|
||||
func (a *ACLAuthMethods) Create(authMethod *ACLAuthMethod, w *WriteOptions) (*ACLAuthMethod, *WriteMeta, error) {
|
||||
if authMethod.Name == "" {
|
||||
return nil, errMissingACLAuthMethodName
|
||||
return nil, nil, errMissingACLAuthMethodName
|
||||
}
|
||||
wm, err := a.client.write("/v1/acl/auth-method", authMethod, nil, w)
|
||||
var resp ACLAuthMethod
|
||||
wm, err := a.client.write("/v1/acl/auth-method", authMethod, &resp, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
return wm, nil
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
// Update is used to update an existing ACL auth-method.
|
||||
func (a *ACLAuthMethods) Update(authMethod *ACLAuthMethod, w *WriteOptions) (*WriteMeta, error) {
|
||||
func (a *ACLAuthMethods) Update(authMethod *ACLAuthMethod, w *WriteOptions) (*ACLAuthMethod, *WriteMeta, error) {
|
||||
if authMethod.Name == "" {
|
||||
return nil, errMissingACLAuthMethodName
|
||||
return nil, nil, errMissingACLAuthMethodName
|
||||
}
|
||||
wm, err := a.client.write("/v1/acl/auth-method/"+authMethod.Name, authMethod, nil, w)
|
||||
var resp ACLAuthMethod
|
||||
wm, err := a.client.write("/v1/acl/auth-method/"+authMethod.Name, authMethod, &resp, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, nil, err
|
||||
}
|
||||
return wm, nil
|
||||
return &resp, wm, nil
|
||||
}
|
||||
|
||||
// Delete is used to delete an ACL auth-method.
|
||||
|
||||
@@ -209,7 +209,7 @@ func TestACLTokens_CreateUpdate(t *testing.T) {
|
||||
out2.Roles = []*ACLTokenRoleLink{{Name: aclRoleCreateResp.Name}}
|
||||
out2.ExpirationTTL = 0
|
||||
|
||||
out3, writeMeta, err = at.Update(out2, nil)
|
||||
out3, _, err = at.Update(out2, nil)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, out3)
|
||||
require.Len(t, out3.Policies, 1)
|
||||
@@ -608,7 +608,7 @@ func TestACLAuthMethods(t *testing.T) {
|
||||
MaxTokenTTL: 15 * time.Minute,
|
||||
Default: true,
|
||||
}
|
||||
writeMeta, err := testClient.ACLAuthMethods().Create(&authMethod, nil)
|
||||
_, writeMeta, err := testClient.ACLAuthMethods().Create(&authMethod, nil)
|
||||
must.NoError(t, err)
|
||||
assertWriteMeta(t, writeMeta)
|
||||
|
||||
@@ -632,7 +632,7 @@ func TestACLAuthMethods(t *testing.T) {
|
||||
|
||||
// Update the auth-method token locality.
|
||||
authMethod.TokenLocality = ACLAuthMethodTokenLocalityGlobal
|
||||
writeMeta, err = testClient.ACLAuthMethods().Update(&authMethod, nil)
|
||||
_, writeMeta, err = testClient.ACLAuthMethods().Update(&authMethod, nil)
|
||||
must.NoError(t, err)
|
||||
assertWriteMeta(t, writeMeta)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user