refactor(system): drop idempotent flag from create-user response body
parent
384fbcf7ed
commit
c591f16d53
|
|
@ -23489,10 +23489,6 @@ const docTemplate = `{
|
|||
"description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.",
|
||||
"type": "string"
|
||||
},
|
||||
"idempotent": {
|
||||
"description": "Idempotent is true when the identity already existed (HTTP 200).\nThe SPA axios interceptor discards status codes, so this flag is\nthe body-level signal that nothing was created or changed.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23482,10 +23482,6 @@
|
|||
"description": "GeneratedPassword is the plaintext password when the server\nauto-generated one. Absent when the caller supplied the password.",
|
||||
"type": "string"
|
||||
},
|
||||
"idempotent": {
|
||||
"description": "Idempotent is true when the identity already existed (HTTP 200).\nThe SPA axios interceptor discards status codes, so this flag is\nthe body-level signal that nothing was created or changed.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"user": {
|
||||
"$ref": "#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5064,12 +5064,6 @@ definitions:
|
|||
GeneratedPassword is the plaintext password when the server
|
||||
auto-generated one. Absent when the caller supplied the password.
|
||||
type: string
|
||||
idempotent:
|
||||
description: |-
|
||||
Idempotent is true when the identity already existed (HTTP 200).
|
||||
The SPA axios interceptor discards status codes, so this flag is
|
||||
the body-level signal that nothing was created or changed.
|
||||
type: boolean
|
||||
user:
|
||||
$ref: '#/definitions/github_com_Tencent_WeKnora_internal_types.UserInfo'
|
||||
type: object
|
||||
|
|
|
|||
|
|
@ -1596,10 +1596,6 @@ type CreateSystemUserResponse struct {
|
|||
// GeneratedPassword is the plaintext password when the server
|
||||
// auto-generated one. Absent when the caller supplied the password.
|
||||
GeneratedPassword string `json:"generated_password,omitempty"`
|
||||
// Idempotent is true when the identity already existed (HTTP 200).
|
||||
// The SPA axios interceptor discards status codes, so this flag is
|
||||
// the body-level signal that nothing was created or changed.
|
||||
Idempotent bool `json:"idempotent,omitempty"`
|
||||
}
|
||||
|
||||
// CreateSystemUser godoc
|
||||
|
|
@ -1658,7 +1654,7 @@ func (h *SystemHandler) CreateSystemUser(c *gin.Context) {
|
|||
"password_generated": false,
|
||||
"idempotent": true,
|
||||
})
|
||||
c.JSON(http.StatusOK, CreateSystemUserResponse{User: user.ToUserInfo(), Idempotent: true})
|
||||
c.JSON(http.StatusOK, CreateSystemUserResponse{User: user.ToUserInfo()})
|
||||
case errors.Is(err, service.ErrPasswordPolicy):
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
case errors.Is(err, service.ErrUserIdentityConflict):
|
||||
|
|
|
|||
|
|
@ -91,9 +91,6 @@ func TestCreateSystemUserCreatesUserWithExplicitPassword(t *testing.T) {
|
|||
resp.GeneratedPassword,
|
||||
)
|
||||
}
|
||||
if resp.Idempotent {
|
||||
t.Fatal("fresh create must not set idempotent")
|
||||
}
|
||||
if users.gotReq == nil || users.gotReq.Password == nil || *users.gotReq.Password != "PlainPass9" {
|
||||
t.Fatalf("service received unexpected request: %+v", users.gotReq)
|
||||
}
|
||||
|
|
@ -136,9 +133,6 @@ func TestCreateSystemUserAutoGeneratesPasswordWhenEmpty(t *testing.T) {
|
|||
if resp.GeneratedPassword != "G3n3r4t3dP4ssw0rd" {
|
||||
t.Fatalf("generated_password=%q, want the once-only generated password", resp.GeneratedPassword)
|
||||
}
|
||||
if resp.Idempotent {
|
||||
t.Fatal("fresh auto-generate create must not set idempotent")
|
||||
}
|
||||
if users.gotReq == nil || users.gotReq.Password != nil {
|
||||
t.Fatalf("absent password must reach the service as nil, got %+v", users.gotReq)
|
||||
}
|
||||
|
|
@ -266,9 +260,6 @@ func TestCreateSystemUserDuplicateIdentityReturnsExistingUser(t *testing.T) {
|
|||
if resp.GeneratedPassword != "" {
|
||||
t.Fatalf("generated_password=%q, want empty for an existing user", resp.GeneratedPassword)
|
||||
}
|
||||
if !resp.Idempotent {
|
||||
t.Fatal("duplicate identity 200 must set idempotent=true so the SPA can tell it from a 201")
|
||||
}
|
||||
if len(audits.entries) != 1 || audits.entries[0].Action != types.AuditActionSystemUserCreated {
|
||||
t.Fatalf("expected one %s audit entry, got %+v", types.AuditActionSystemUserCreated, audits.entries)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue