diff --git a/api-docs.yml b/api-docs.yml index 77543817..b36b7547 100644 --- a/api-docs.yml +++ b/api-docs.yml @@ -50,12 +50,35 @@ definitions: name: type: string x-example: Integration Test User + example: Integration Test User username: type: string x-example: test-user + example: test-user email: type: string x-example: test@ansiblesemaphore.test + example: test@ansiblesemaphore.test + alert: + type: boolean + admin: + type: boolean + + UserPutRequest: + type: object + properties: + name: + type: string + x-example: Integration Test User2 + example: Integration Test User2 + username: + type: string + x-example: test-user2 + example: test-user2 + email: + type: string + x-example: test2@ansiblesemaphore.test + example: test2@ansiblesemaphore.test alert: type: boolean admin: @@ -131,6 +154,7 @@ definitions: type: string secret: type: string + example: test AccessKey: type: object properties: @@ -618,7 +642,7 @@ paths: in: body required: true schema: - $ref: "#/definitions/UserRequest" + $ref: "#/definitions/UserPutRequest" responses: 204: description: User Updated diff --git a/api/api_test.go b/api/api_test.go index 68d9553c..9236228a 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -7,20 +7,10 @@ import ( "os" "testing" - "github.com/ansible-semaphore/semaphore/util" "github.com/go-openapi/loads" "github.com/go-openapi/spec" ) -func mockParam(w http.ResponseWriter, r *http.Request) { - _, err := util.GetIntParam("test_id", w, r) - if err != nil { - return - } - - w.WriteHeader(200) -} - func TestApiPing(t *testing.T) { req, _ := http.NewRequest("GET", "/api/ping", nil) rr := httptest.NewRecorder() diff --git a/api/users.go b/api/users.go index a896ae87..9a5d4930 100644 --- a/api/users.go +++ b/api/users.go @@ -102,7 +102,9 @@ func updateUser(w http.ResponseWriter, r *http.Request) { } if _, err := db.Mysql.Exec("update user set name=?, username=?, email=?, alert=?, admin=? where id=?", user.Name, user.Username, user.Email, user.Alert, user.Admin, oldUser.ID); err != nil { - panic(err) + log.Error(err.Error()) + w.WriteHeader(http.StatusBadRequest) + return } w.WriteHeader(http.StatusNoContent)