-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(AttendeeEncryptedPasswordFixture): 암호화된 비밀번호 Fixture 추가
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
backend/src/test/java/kr/momo/domain/attendee/AttendeeEncryptedPasswordFixture.java
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package kr.momo.domain.attendee; | ||
|
||
import java.lang.reflect.Field; | ||
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
public class AttendeeEncryptedPasswordFixture { | ||
|
||
private AttendeeEncryptedPasswordFixture() { | ||
} | ||
|
||
private static final PasswordEncoder passwordEncoder = Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8(); | ||
|
||
public static AttendeePassword createAttendeePassword(String rawPassword) throws Exception { | ||
AttendeePassword attendeePassword = AttendeePassword.class.getDeclaredConstructor().newInstance(); | ||
|
||
Field passwordField = AttendeePassword.class.getDeclaredField("password"); | ||
passwordField.setAccessible(true); | ||
passwordField.set(attendeePassword, passwordEncoder.encode(rawPassword)); | ||
return attendeePassword; | ||
} | ||
} |
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