Auth Method API Handler for CRUDL (not updating password specific fields)(#239)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-08-06 12:50:20 -07:00
1 parent 7fefd5e2fe
commit b7bf76a9ba
15 files changed
+3676 -21

No files matched your search

@@ -208,15 +208,14 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, authMethod *AuthMetho
dbOpts...,
)
if err == nil && rowsUpdated > 1 {
// return err, which will result in a rollback of the update
return errors.New("error more than 1 resource would have been updated ")
return db.ErrMultipleRecords
}
return err
},
)
if err != nil {
if db.IsUniqueError(err) {
return nil, db.NoRowsAffected, fmt.Errorf("update: password auth method: authMethod %s already exists in scope %s", authMethod.Name, authMethod.ScopeId)
return nil, db.NoRowsAffected, fmt.Errorf("update: password auth method: authMethod %s already exists in scope %s: %w", authMethod.Name, authMethod.ScopeId, db.ErrNotUnique)
}
return nil, db.NoRowsAffected, fmt.Errorf("update: password auth method: %w for %s", err, authMethod.PublicId)
}
@@ -496,6 +496,15 @@ func TestRepository_UpdateAuthMethod(t *testing.T) {
wantErr: false,
wantRowsUpdate: 1,
},
{
name: "null name ignored description",
args: args{
updates: &store.AuthMethod{Description: "ignored"},
fieldMaskPaths: []string{"name"},
},
wantErr: false,
wantRowsUpdate: 1,
},
{
name: "change min pw",
args: args{