-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(api) add more invalid body tests
- Loading branch information
Showing
4 changed files
with
41 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ func getUserToken(email string, password string) string { | |
return acc.Token | ||
} | ||
|
||
func TestCreateUserInvalidBody(t *testing.T) { | ||
e2e.TestInvalidBody(t, "POST", "/api/users", "Invalid request: wrong format body") | ||
} | ||
|
||
// Tests domain bulk creation (/api/users/bulk) | ||
func TestCreateBulkUsersInvalidBody(t *testing.T) { | ||
requestBody := []byte(`[ | ||
|
@@ -84,6 +88,11 @@ func TestCreateBulkUsers(t *testing.T) { | |
assert.False(t, exists) | ||
} | ||
|
||
// Tests Login | ||
func TestLoginInvalidBody(t *testing.T) { | ||
e2e.TestInvalidBody(t, "POST", "/api/login", "Invalid request") | ||
} | ||
|
||
func TestLoginWrongPassword(t *testing.T) { | ||
requestBody := []byte(`{ | ||
"email": "[email protected]", | ||
|
@@ -272,6 +281,11 @@ func TestDeleteWithInvalidIdReturnsError(t *testing.T) { | |
} | ||
|
||
// Tests modify user role | ||
func TestModifyUserInvalidBody(t *testing.T) { | ||
userId := models.GetUserByEmail("[email protected]").ID.Hex() | ||
e2e.TestInvalidBody(t, "PATCH", "/api/users/"+userId, "Invalid request") | ||
} | ||
|
||
func TestModifyRoleWithMoreDataReturnsError(t *testing.T) { | ||
// we get the user ID | ||
userId := models.GetUserByEmail("[email protected]").ID.Hex() | ||
|
@@ -381,6 +395,10 @@ func TestModifyRoleSuccess(t *testing.T) { | |
} | ||
|
||
// Tests modify and reset user password | ||
func TestModifyPasswordInvalidBody(t *testing.T) { | ||
e2e.TestInvalidBody(t, "POST", "/api/users/password/change", "Invalid request") | ||
} | ||
|
||
func TestModifyPasswordNotEnoughArguments(t *testing.T) { | ||
userToken := getUserToken("[email protected]", "fake_password") | ||
requestBody := []byte(`{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters