Skip to content

Commit

Permalink
test(AttendeeEncryptedPasswordFixture): 암호화된 비밀번호 Fixture 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ikjo39 committed Sep 12, 2024
1 parent d9acc33 commit 6be03f6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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;
}
}
4 changes: 4 additions & 0 deletions backend/src/test/java/kr/momo/fixture/AttendeeFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public Attendee create(Meeting meeting) {
return new Attendee(meeting, new AttendeeName(name), new AttendeePassword(password), role);
}

public Attendee create(Meeting meeting, AttendeePassword attendeePassword) {
return new Attendee(meeting, new AttendeeName(name), attendeePassword, role);
}

public String getName() {
return name;
}
Expand Down

0 comments on commit 6be03f6

Please sign in to comment.