-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ControllerTest and RestDoc Tests #3583
- Loading branch information
1 parent
1226a27
commit 9c32b97
Showing
8 changed files
with
32 additions
and
26 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
package com.mercedesbenz.sechub.domain.administration.user; | ||
|
||
import static com.mercedesbenz.sechub.test.RestDocPathParameter.EMAIL_ADDRESS; | ||
import static com.mercedesbenz.sechub.test.SecHubTestURLBuilder.https; | ||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.mockito.Mockito.*; | ||
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
@@ -82,13 +84,14 @@ public void fetchUserDetailInformation__is_not_accessible_by_unauthenticated_use | |
public void updateUserEmailAddress__is_accessible_by_authenticated_user() throws Exception { | ||
/* prepare */ | ||
String newEmailAddress = "[email protected]"; | ||
String apiEndpoint = https(PORT_USED).buildUserUpdatesEmailUrl(newEmailAddress); | ||
String apiEndpoint = https(PORT_USED).buildUserRequestUpdatesEmailUrl(EMAIL_ADDRESS.pathElement()); | ||
doNothing().when(emailAddressUpdateService).userRequestUpdateMailAddress(newEmailAddress); | ||
|
||
/* execute + test */ | ||
/* @formatter:off */ | ||
this.mockMvc.perform( | ||
post(apiEndpoint)) | ||
post(apiEndpoint, newEmailAddress) | ||
.with(csrf())) | ||
.andExpect(status().isOk()); | ||
/* @formatter:on */ | ||
|
||
|
@@ -98,13 +101,14 @@ public void updateUserEmailAddress__is_accessible_by_authenticated_user() throws | |
@Test | ||
public void updateUserEmailAddress__is_not_accessible_by_unauthenticated_user() throws Exception { | ||
/* prepare */ | ||
String newEmailAddress = "test-user[email protected]"; | ||
String apiEndpoint = https(PORT_USED).buildUserUpdatesEmailUrl(newEmailAddress); | ||
String newEmailAddress = "testuser[email protected]"; | ||
String apiEndpoint = https(PORT_USED).buildUserRequestUpdatesEmailUrl(EMAIL_ADDRESS.pathElement()); | ||
|
||
/* execute + test */ | ||
/* @formatter:off */ | ||
this.mockMvc.perform( | ||
post(apiEndpoint)) | ||
post(apiEndpoint, newEmailAddress) | ||
.with(csrf())) | ||
.andExpect(status().isUnauthorized()); | ||
/* @formatter:on */ | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ public void restDoc__userFetchesUserDetailInformation() throws Exception { | |
public void restDoc__userUpdatesEmailAddress() throws Exception { | ||
/* prepare */ | ||
String newMailAddress = "[email protected]"; | ||
String apiEndpoint = https(PORT_USED).buildUserUpdatesEmailUrl(EMAIL_ADDRESS.pathElement()); | ||
String apiEndpoint = https(PORT_USED).buildUserRequestUpdatesEmailUrl(EMAIL_ADDRESS.pathElement()); | ||
|
||
Class<? extends Annotation> useCase = UseCaseUserUpdatesEmailAddress.class; | ||
|
||
|
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