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

test : CI/CD test #9 #83

Closed
wants to merge 12 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {


try {
Map<String, Object> claims = verifyJws(request, response);
setAuthenticationToContext(claims);
Expand Down Expand Up @@ -64,16 +63,26 @@ private Map<String, Object> verifyJws(HttpServletRequest request,
return claims;
}

/**
* 계정이 있는지 없는지만 검증하고있다.
* 스케쥴러가 없어서 RefreshToken을 db에 저장하면 데이터가 정리가 안되고 계속해서 쌓일것.
* 보안 필요.
*/

String jws = request.getHeader("Refresh");
Member member = null;
// memberRepository.findByEmail(jwtTokenizer.getUsername(jws))
// .orElseThrow(() -> new BusinessLogicException(ExceptionCode.INVALID_TOKEN));
Member member =
memberService.findByEmail(jwtTokenizer.getUsername(jws));

String accessToken =
jwtTokenizer.delegateAccessToken(
member.getEmail(),
authorityUtils.createRoles(member.getEmail()));

String refreshToken =
jwtTokenizer.delegateRefreshToken(member.getEmail());

response.setHeader("Authorization", "Bearer " + accessToken);
response.setHeader("Refresh", refreshToken);

Claims claims = jwtTokenizer.getClaims(accessToken).getBody();
return claims;
Expand Down
56 changes: 0 additions & 56 deletions server/src/main/java/com/main/server/board/entity/Board.java

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions server/src/main/java/com/main/server/board/status/Status.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

@Configuration
@EnableWebSocket
@EnableWebSocketMessageBroker
@RequiredArgsConstructor
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,4 @@ public Chatroom findVerifiedRoomId(Long chatroomId) {
public Chatroom save(Chatroom chatroom) {
return chatroomRepository.save(chatroom);
}

// public <T> void sendMessage(WebSocketSession session, T message) {
// log.info("sendMessage is used");
// try {
// session.sendMessage(new TextMessage(objectMapper.writeValueAsString(message)));
// } catch (IOException e) {
// log.error(e.getMessage(), e);
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ public enum ExceptionCode {
ALREADY_LIKED(400, "board not found"),
MEMBER_EXISTS(400, "member exists"),
INVALID_TOKEN(400, "invalid token"),
NO_PERMISSION(400, "no permission");
NO_PERMISSION(400, "no permission"),
PLAYLIST_NOT_FOUND(400, "playlist not found");

@Getter
private int status;
Expand Down
15 changes: 2 additions & 13 deletions server/src/main/java/com/main/server/member/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
@Getter
//@Setter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
// 주석 = 바꿔야 할 부분
public class Member extends Auditable {

@Id
Expand All @@ -21,24 +19,17 @@ public class Member extends Auditable {

@Column(length = 100, nullable = false, unique = true)
private String nickname;
// length

@Column(length = 100, nullable = false, unique = true)
private String email;
// length

@Column(length = 500)
private String picture;

// @Column(length = 1000, nullable = false)
// private String password;
// // length

@ElementCollection(fetch = FetchType.EAGER)
@ElementCollection(fetch = FetchType.LAZY)
private List<String> roles = new ArrayList<>();



@Builder
public Member( String nickname,
String email,
Expand All @@ -49,6 +40,4 @@ public Member( String nickname,
this.picture = picture;
this.roles = roles;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.main.server.playlist.controller;

import com.main.server.playlist.dto.PlaylistCreateDto;
import com.main.server.playlist.dto.PlaylistResponseDto;
import com.main.server.playlist.entity.Playlist;
import com.main.server.playlist.service.PlaylistService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/playlists")
public class PlaylistController {

private final PlaylistService playlistService;

@PostMapping
public ResponseEntity createPlaylist(@RequestBody PlaylistCreateDto dto, @AuthenticationPrincipal String email) {
Playlist playlist = playlistService.createPlaylist(dto, "admin@google.com");

return ResponseEntity.status(HttpStatus.CREATED)
.body(PlaylistResponseDto.createByEntity(playlist));
}

@GetMapping("/{playlist-id}")
public ResponseEntity getPlaylist(@PathVariable("playlist-id") Long playlistId) {
return ResponseEntity.status(HttpStatus.OK)
.body(PlaylistResponseDto.createByEntity(playlistService.findPlaylistById(playlistId)));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.main.server.playlist.dto;

import com.main.server.song.dto.SongCreateDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PlaylistCreateDto {

private String title;

private String thumbnail;

private List<SongCreateDto> songList;
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading