use of wooteco.prolog.login.application.dto.GithubProfileResponse in project prolog by woowacourse.
the class StudylogTagServiceTest method setUp.
@BeforeEach
void setUp() {
SessionResponse session = sessionService.create(new SessionRequest("세션1"));
MissionResponse mission = missionService.create(new MissionRequest("미션 이름", session.getId()));
this.member = memberService.findOrCreateMember(new GithubProfileResponse("이름", "별명", "1", "image"));
}
use of wooteco.prolog.login.application.dto.GithubProfileResponse in project prolog by woowacourse.
the class MemberServiceTest method findOrCreateMemberTest.
@DisplayName("Member 조회 성공시 정보를 가져오고, 실패시 Member를 생성한다.")
@Test
void findOrCreateMemberTest() {
// given
GithubProfileResponse brownResponse = new GithubProfileResponse("브라운", "gracefulBrown", "1", "imageUrl1");
GithubProfileResponse jasonResponse = new GithubProfileResponse("제이슨", "pjs", "2", "imageUrl2");
Member를_생성한다(brownResponse.toMember());
// when
Member brown = memberService.findOrCreateMember(brownResponse);
Member jason = memberService.findOrCreateMember(jasonResponse);
// then
assertThat(memberRepository.findById(brown.getId())).isPresent();
assertThat(memberRepository.findById(jason.getId())).isPresent();
}
use of wooteco.prolog.login.application.dto.GithubProfileResponse in project prolog by woowacourse.
the class StudylogTagServiceTest method setUp.
@BeforeEach
void setUp() {
SessionResponse session = sessionService.create(new SessionRequest("세션1"));
MissionResponse mission = missionService.create(new MissionRequest("미션 이름", session.getId()));
this.member = memberService.findOrCreateMember(new GithubProfileResponse("이름", "별명", "1", "image"));
}
use of wooteco.prolog.login.application.dto.GithubProfileResponse in project prolog by woowacourse.
the class GithubLoginService method createToken.
public TokenResponse createToken(TokenRequest tokenRequest) {
String githubAccessToken = githubClient.getAccessTokenFromGithub(tokenRequest.getCode());
GithubProfileResponse githubProfile = githubClient.getGithubProfileFromGithub(githubAccessToken);
Member member = memberService.findOrCreateMember(githubProfile);
String accessToken = jwtTokenProvider.createToken(member);
return TokenResponse.of(accessToken);
}
use of wooteco.prolog.login.application.dto.GithubProfileResponse in project prolog by woowacourse.
the class GithubClient method getGithubProfileFromGithub.
public GithubProfileResponse getGithubProfileFromGithub(String accessToken) {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "token " + accessToken);
HttpEntity httpEntity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
try {
return restTemplate.exchange(profileUrl, HttpMethod.GET, httpEntity, GithubProfileResponse.class).getBody();
} catch (HttpClientErrorException e) {
throw new GithubConnectionException();
}
}
Aggregations