-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#97 - Update test authentication settings
Add configuration to the test so that Spring Security can accept both existing DB authentication and OAuth authentication.
- Loading branch information
Showing
1 changed file
with
13 additions
and
5 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.laphayen.projectboard.config; | ||
|
||
import com.laphayen.projectboard.domain.UserAccount; | ||
import com.laphayen.projectboard.repository.UserAccountRepository; | ||
import com.laphayen.projectboard.dto.UserAccountDto; | ||
import com.laphayen.projectboard.service.UserAccountService; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.test.context.event.annotation.BeforeTestMethod; | ||
|
@@ -14,17 +14,25 @@ | |
@Import(SecurityConfig.class) | ||
public class TestSecurityConfig { | ||
|
||
@MockBean private UserAccountRepository userAccountRepository; | ||
@MockBean private UserAccountService userAccountService; | ||
|
||
@BeforeTestMethod | ||
public void securitySetUp() { | ||
given(userAccountRepository.findById(anyString())).willReturn(Optional.of(UserAccount.of( | ||
given(userAccountService.searchUser(anyString())) | ||
.willReturn(Optional.of(createUserAccountDto())); | ||
given(userAccountService.saveUser(anyString(), anyString(), anyString(), anyString(), anyString())) | ||
.willReturn(createUserAccountDto()); | ||
} | ||
|
||
|
||
private UserAccountDto createUserAccountDto() { | ||
return UserAccountDto.of( | ||
"laphayenTest", | ||
"qwer1234", | ||
"[email protected]", | ||
"laphayen", | ||
"test memo" | ||
))); | ||
); | ||
} | ||
|
||
} |