Skip to content
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

Feature/refactoring #354

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

DongilMin
Copy link

  • cookie/CookieUtilsTest.java : JUnit방식의 전통적인 가독성이 떨어지는 코드를 개선, 중복 코드 분리, 가독성을 위해 상수 사용

  • cookie/HttpCookieOAuth2HttpCookieOAuth2AuthorizationRequestRepositoryTest.java : BeforeEach 추가, Unit방식의 전통적인 가독성이 떨어지는 코드를 개선, 중복 코드 분리, 가독성을 위해 상수 사용

  • handler/Oauth2AuthenticationFailureHandlerTest.java : 중복 코드 메서드 분리, URL과 같은 반복적으로 사용되는 문자열은 상수로 정의하여 코드의 가독성 증가

  • handler/Oauth2AuthenticationFailureHandlerTest.java : 중복 코드 메서드 분리, URL과 같은 반복적으로 사용되는 문자열은 상수로 정의하여 코드의 가독성 증가, 오타 수정

  • majorInfo/domain/valueObject/CollegeTest : 메서드 이름 개선

  • majorInfo/domain/valueObject/majorTest : 메서드 이름 개선

  • majorInfo/usecase/MajorInfoTest : createSampleMajorInfos와 createMajorInfo 메서드를 추가, 메서드 이름 개선

[build Message]

Task :module-auth:test
2024-11-03 18:34:34.063 INFO 26123 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2024-11-03 18:34:34.064 INFO 26123 --- [ionShutdownHook] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
Hibernate: drop table if exists major CASCADE
Hibernate: drop table if exists refresh_token CASCADE
Hibernate: drop table if exists update_name_request CASCADE
Hibernate: drop table if exists user CASCADE
Hibernate: drop table if exists user_socialaccount CASCADE
2024-11-03 18:34:34.077 INFO 26123 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-11-03 18:34:34.082 INFO 26123 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

BUILD SUCCESSFUL in 27s

@DongilMin DongilMin deployed to build_gradle November 3, 2024 09:47 — with GitHub Actions Active
private static final String COOKIE_NAME = "myCookie";
private static final String COOKIE_CONTENTS = "hello";
private static final int COOKIE_MAX_AGE = 180;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중복을 제거하고 가독성 향상을 위해 상수 추가

.clientId("1234")
.redirectUri("http://localhost/api/login/oauth2/code/kakao")
.scopes(Set.of("gender", "profile_image", "account_email", "profile_nickname"))
.state("state1934")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중복되는 부분 함수로 처리


// when
String serializedRequest = CookieUtils.serialize(request);

// then
assertTrue(Base64.isBase64(serializedRequest));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue를 assertThat으로 변경

public void setUp() {
repository = new HttpCookieOAuth2AuthorizationRequestRepository();
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repository 객체를 각 테스트 메서드에서 개별적으로 초기화하는 대신 @beforeeach 메서드를 사용하여 모든 테스트가 실행되기 전에 한 번만 초기화하도록 한다.

assert savedCookie != null;
assertTrue(Base64.isBase64(savedCookie.getValue()));
assertThat(savedCookie).isNotNull();
assertThat(Base64.isBase64(savedCookie.getValue())).isTrue();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue를 assertThat으로 수정

assertTrue(cookie.getValue().isBlank() && cookie.getMaxAge() == 0);
assertThat(cookie).isNotNull();
assertThat(cookie.getValue()).isBlank();
assertThat(cookie.getMaxAge()).isEqualTo(0);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue를 assertThat으로 수정

} catch (InvocationTargetException | InstantiationException | IllegalAccessException ignored) {
return null;
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Failed to create OAuth2AuthorizationRequest", e);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외처리시 null을 반환하는 것보다, 해당 정보를 반환하여 문제를 알리도록 변경

private static final String VALID_REDIRECT_URL = "https://www.inhabas.com";
private static final String INVALID_REDIRECT_URL = "https://www.unauthorized_url.com";
private static final String ERROR_CODE = OAuth2ErrorCodes.INVALID_REQUEST;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

중복 방지와 가독성을 위한 상수 추가

@@ -12,7 +12,7 @@ public class CollegeTest {

@DisplayName("College 타입에 제목을 저장한다.")
@Test
public void College_is_OK() {
public void saveValidCollegeName() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

메서드 이름 개선

add(majorInfo3);
}
};

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수로 따로 처리하여 가독성 향상

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant