diff options
author | Zettat123 <zettat123@gmail.com> | 2024-03-11 14:07:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 06:07:36 +0000 |
commit | 4129e0e79bbf30e4297efd33feb2602c40322d10 (patch) | |
tree | 8b9b9d18835cc3dfd290f204f8802e7df860a0f8 /tests | |
parent | 8fc1a8f0eb642c574610a346e858d42c433ebe01 (diff) | |
download | gitea-4129e0e79bbf30e4297efd33feb2602c40322d10.tar.gz gitea-4129e0e79bbf30e4297efd33feb2602c40322d10.zip |
Add a warning for disallowed email domains (#29658)
Resolve #29660
Follow #29522 and #29609
Add a warning for disallowed email domains when admins manually add/edit
users.
Thanks @yp05327 for the
[comment](https://github.com/go-gitea/gitea/pull/29605#issuecomment-1980105119)
![image](https://github.com/go-gitea/gitea/assets/15528715/6737b221-a3a2-4180-9ef8-b846c10f96e0)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/api_admin_test.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/integration/api_admin_test.go b/tests/integration/api_admin_test.go index 8a330a68e2..e8954f5b20 100644 --- a/tests/integration/api_admin_test.go +++ b/tests/integration/api_admin_test.go @@ -354,7 +354,8 @@ func TestAPICreateUser_NotAllowedEmailDomain(t *testing.T) { "password": "allowedUser1_pass", "must_change_password": "true", }).AddTokenAuth(token) - MakeRequest(t, req, http.StatusCreated) + resp := MakeRequest(t, req, http.StatusCreated) + assert.Equal(t, "the domain of user email allowedUser1@example1.org conflicts with EMAIL_DOMAIN_ALLOWLIST or EMAIL_DOMAIN_BLOCKLIST", resp.Header().Get("X-Gitea-Warning")) req = NewRequest(t, "DELETE", "/api/v1/admin/users/allowedUser1").AddTokenAuth(token) MakeRequest(t, req, http.StatusNoContent) @@ -378,7 +379,8 @@ func TestAPIEditUser_NotAllowedEmailDomain(t *testing.T) { SourceID: 0, Email: &newEmail, }).AddTokenAuth(token) - MakeRequest(t, req, http.StatusOK) + resp := MakeRequest(t, req, http.StatusOK) + assert.Equal(t, "the domain of user email user2@example1.com conflicts with EMAIL_DOMAIN_ALLOWLIST or EMAIL_DOMAIN_BLOCKLIST", resp.Header().Get("X-Gitea-Warning")) originalEmail := "user2@example.com" req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditUserOption{ |