-
Notifications
You must be signed in to change notification settings - Fork 12
테스트 환경 PasswordEncoder 빈 등록 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a test‐only Pbkdf2PasswordEncoder bean and verifies it in integration tests.
- Define a
PasswordEncoderConfigurationclass to register aPbkdf2PasswordEncoderfor tests - Update the
@CommerceApiTestmeta‐annotation to include the new configuration - Add a new test in
CommerceApiApp_specsto assert thePasswordEncoderbean type
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/test/java/test/commerce/api/PasswordEncoderConfiguration.java | Introduce a test configuration class providing a password encoder bean |
| src/test/java/test/commerce/api/CommerceApiTest.java | Extend the custom test annotation to load the new config |
| src/test/java/test/commerce/CommerceApiApp_specs.java | Add a test to verify the PasswordEncoder bean is available |
Comments suppressed due to low confidence (1)
src/test/java/test/commerce/CommerceApiApp_specs.java:12
- This test uses @SpringBootTest directly against CommerceApiApp, so it won’t load the PasswordEncoderConfiguration. Either switch to @CommerceApiTest or include PasswordEncoderConfiguration in the classes list.
@SpringBootTest(classes = CommerceApiApp.class)
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; | ||
|
|
||
| import static org.springframework.security.crypto.password.Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256; | ||
|
|
Copilot
AI
May 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class is not annotated with @configuration or @TestConfiguration, so its @bean method won’t be picked up. Add @TestConfiguration to register the bean in the test context.
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.context.annotation.Primary; | |
| import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; | |
| import static org.springframework.security.crypto.password.Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.boot.test.context.TestConfiguration; | |
| import org.springframework.context.annotation.Primary; | |
| import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; | |
| import static org.springframework.security.crypto.password.Pbkdf2PasswordEncoder.SecretKeyFactoryAlgorithm.PBKDF2WithHmacSHA256; | |
| @TestConfiguration |
|
|
||
| @Bean | ||
| @Primary | ||
| Pbkdf2PasswordEncoder testPasswordEncoder() { | ||
| return new Pbkdf2PasswordEncoder("", 16, 10, PBKDF2WithHmacSHA256); |
Copilot
AI
May 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Extract the magic numbers (salt length 16 and iteration count 10) into named constants or add comments to clarify their purpose.
| @Bean | |
| @Primary | |
| Pbkdf2PasswordEncoder testPasswordEncoder() { | |
| return new Pbkdf2PasswordEncoder("", 16, 10, PBKDF2WithHmacSHA256); | |
| private static final int SALT_LENGTH = 16; // Length of the salt in bytes | |
| private static final int ITERATION_COUNT = 10; // Number of hash iterations | |
| @Bean | |
| @Primary | |
| Pbkdf2PasswordEncoder testPasswordEncoder() { | |
| return new Pbkdf2PasswordEncoder("", SALT_LENGTH, ITERATION_COUNT, PBKDF2WithHmacSHA256); |
No description provided.