Skip to content

Commit

Permalink
[HOTFIX] stomp 헤더 사용하지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Jan 15, 2024
1 parent c12d25d commit b4672fd
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 82 deletions.
3 changes: 3 additions & 0 deletions backend/src/docs/member.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ operation::get duplicate nickname[snippets='http-request,http-response']

=== 닉네임으로 멤버 검색
operation::get member nickname[snippets='http-request,http-response']

=== 닉네임으로 멤버 검색
operation::get member id[snippets='http-request,http-response']
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public SecurityFilterChain configure(HttpSecurity http) throws Exception {
"auth/save",
"auth/login",
"member/duplicate/**",
"plan/**",
"actuator/**")
.permitAll()
.anyRequest()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.twtw.backend.config.socket;

import com.twtw.backend.global.properties.RabbitMQProperties;

import lombok.RequiredArgsConstructor;

import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
Expand All @@ -20,7 +17,6 @@
public class StompConfig implements WebSocketMessageBrokerConfigurer {

private final RabbitMQProperties rabbitMQProperties;
private final StompHandler stompHandler;

@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
Expand All @@ -39,9 +35,4 @@ public void configureMessageBroker(final MessageBrokerRegistry registry) {

registry.setApplicationDestinationPrefixes("/pub");
}

@Override
public void configureClientInboundChannel(ChannelRegistration registration) {
registration.interceptors(stompHandler);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class LocationRequest {
private UUID memberId;
private String nickname;
private Double longitude;
private Double latitude;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import com.twtw.backend.domain.location.dto.response.LocationResponse;
import com.twtw.backend.domain.location.mapper.LocationMapper;
import com.twtw.backend.domain.member.entity.Member;
import com.twtw.backend.domain.member.service.AuthService;
import com.twtw.backend.domain.member.service.MemberService;
import com.twtw.backend.domain.plan.entity.Plan;
import com.twtw.backend.domain.plan.service.PlanService;

import lombok.RequiredArgsConstructor;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -22,13 +20,13 @@
public class LocationService {

private final LocationMapper locationMapper;
private final AuthService authService;
private final MemberService memberService;
private final PlanService planService;
private final GeoService geoService;

@Transactional
public LocationResponse addInfo(final UUID planId, final LocationRequest locationRequest) {
final Member member = authService.getMemberByJwt();
final Member member = memberService.getMemberById(locationRequest.getMemberId());
final Plan plan = planService.getPlanEntity(planId);

plan.updateMemberLocation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.twtw.backend.domain.member.controller;

import com.twtw.backend.domain.member.dto.response.DuplicateNicknameResponse;
import com.twtw.backend.domain.member.dto.response.IdResponse;
import com.twtw.backend.domain.member.dto.response.MemberResponse;
import com.twtw.backend.domain.member.service.MemberService;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -28,4 +28,9 @@ public ResponseEntity<List<MemberResponse>> searchMemberByNickname(
@RequestParam(name = "nickname") String nickname) {
return ResponseEntity.ok(memberService.getMemberByNickname(nickname));
}

@GetMapping("/me")
public ResponseEntity<IdResponse> getMemberByJwt() {
return ResponseEntity.ok(memberService.getMemberId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.twtw.backend.domain.member.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.UUID;

@Getter
@AllArgsConstructor
public class IdResponse {
private UUID id;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.twtw.backend.domain.member.service;

import com.twtw.backend.domain.member.dto.response.DuplicateNicknameResponse;
import com.twtw.backend.domain.member.dto.response.IdResponse;
import com.twtw.backend.domain.member.dto.response.MemberResponse;
import com.twtw.backend.domain.member.entity.Member;
import com.twtw.backend.domain.member.mapper.MemberMapper;
Expand Down Expand Up @@ -60,4 +61,8 @@ public List<MemberResponse> getMemberResponses(final Plan plan) {
public List<Member> getMembersByIds(final List<UUID> friendMemberIds) {
return memberRepository.findAllById(friendMemberIds);
}

public IdResponse getMemberId() {
return new IdResponse(authService.getMemberByJwt().getId());
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
package com.twtw.backend.domain.member.controller;

import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest;
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.twtw.backend.domain.member.dto.response.DuplicateNicknameResponse;
import com.twtw.backend.domain.member.dto.response.IdResponse;
import com.twtw.backend.domain.member.dto.response.MemberResponse;
import com.twtw.backend.domain.member.service.MemberService;
import com.twtw.backend.support.docs.RestDocsTest;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
Expand All @@ -26,6 +15,16 @@
import java.util.List;
import java.util.UUID;

import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentRequest;
import static com.twtw.backend.support.docs.ApiDocsUtils.getDocumentResponse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@DisplayName("MemberController의")
@WebMvcTest(MemberController.class)
public class MemberControllerTest extends RestDocsTest {
Expand Down Expand Up @@ -84,4 +83,31 @@ void searchMemberByNickname() throws Exception {
getDocumentRequest(),
getDocumentResponse()));
}

@Test
@DisplayName("Member id가 조회되는가")
void getMemberId() throws Exception {
// given
final IdResponse expected = new IdResponse(UUID.randomUUID());
given(memberService.getMemberId()).willReturn(expected);

// when
final ResultActions perform =
mockMvc.perform(
get("/member/me")
.contentType(MediaType.APPLICATION_JSON)
.header(
"Authorization",
"Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh"));

// then
perform.andExpect(status().isOk());

perform.andDo(print())
.andDo(
document(
"get member id",
getDocumentRequest(),
getDocumentResponse()));
}
}

0 comments on commit b4672fd

Please sign in to comment.