aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_admin_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrations/api_admin_test.go')
-rw-r--r--integrations/api_admin_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/integrations/api_admin_test.go b/integrations/api_admin_test.go
index 80d6b52289..79fdc4a9f7 100644
--- a/integrations/api_admin_test.go
+++ b/integrations/api_admin_test.go
@@ -5,6 +5,7 @@
package integrations
import (
+ "encoding/json"
"fmt"
"net/http"
"testing"
@@ -163,3 +164,32 @@ func TestAPICreateUserInvalidEmail(t *testing.T) {
})
session.MakeRequest(t, req, http.StatusUnprocessableEntity)
}
+
+func TestAPIEditUser(t *testing.T) {
+ defer prepareTestEnv(t)()
+ adminUsername := "user1"
+ session := loginUser(t, adminUsername)
+ token := getTokenForLoggedInUser(t, session)
+ urlStr := fmt.Sprintf("/api/v1/admin/users/%s?token=%s", "user2", token)
+
+ req := NewRequestWithValues(t, "PATCH", urlStr, map[string]string{
+ // required
+ "login_name": "user2",
+ "source_id": "0",
+ // to change
+ "full_name": "Full Name User 2",
+ })
+ session.MakeRequest(t, req, http.StatusOK)
+
+ empty := ""
+ req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{
+ LoginName: "user2",
+ SourceID: 0,
+ Email: &empty,
+ })
+ resp := session.MakeRequest(t, req, http.StatusUnprocessableEntity)
+
+ errMap := make(map[string]interface{})
+ json.Unmarshal(resp.Body.Bytes(), &errMap)
+ assert.EqualValues(t, "email is not allowed to be empty string", errMap["message"].(string))
+}