-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from PlanIt-Project/BE_test#192
Be test#192
- Loading branch information
Showing
26 changed files
with
4,232 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
26 changes: 26 additions & 0 deletions
26
src/main/java/com/sideProject/PlanIT/common/security/MockSpringSecurityFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.sideProject.PlanIT.common.security; | ||
|
||
import jakarta.servlet.*; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
|
||
import java.io.IOException; | ||
|
||
public class MockSpringSecurityFilter implements Filter { | ||
|
||
@Override | ||
public void init(FilterConfig filterConfig) {} | ||
|
||
@Override | ||
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { | ||
SecurityContextHolder.getContext() | ||
.setAuthentication((Authentication) ((HttpServletRequest) req).getUserPrincipal()); | ||
chain.doFilter(req, res); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
SecurityContextHolder.clearContext(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ public class ApproveRequestDto { | |
public ApproveRequestDto(Long trainer) { | ||
this.trainer = trainer; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...java/com/sideProject/PlanIT/domain/program/dto/request/programRegistrationRequestDto.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/test/java/com/sideProject/PlanIT/domain/controller_test_module/WithMockCustomMember.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.sideProject.PlanIT.domain.controller_test_module; | ||
|
||
import com.sideProject.PlanIT.domain.user.entity.Member; | ||
import com.sideProject.PlanIT.domain.user.entity.enums.MemberRole; | ||
import org.springframework.security.test.context.support.WithSecurityContext; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@WithSecurityContext(factory = WithMockCustomSecurityContextFactory.class) | ||
public @interface WithMockCustomMember { | ||
String first() default "name"; | ||
|
||
MemberRole second() default MemberRole.MEMBER; | ||
} |
28 changes: 28 additions & 0 deletions
28
...ideProject/PlanIT/domain/controller_test_module/WithMockCustomSecurityContextFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.sideProject.PlanIT.domain.controller_test_module; | ||
|
||
import com.sideProject.PlanIT.domain.user.entity.Member; | ||
import com.sideProject.PlanIT.domain.user.entity.enums.Gender; | ||
import com.sideProject.PlanIT.domain.user.entity.enums.MemberRole; | ||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.core.GrantedAuthority; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
import org.springframework.security.core.context.SecurityContext; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.security.test.context.support.WithSecurityContextFactory; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
public class WithMockCustomSecurityContextFactory implements WithSecurityContextFactory<WithMockCustomMember> { | ||
@Override | ||
public SecurityContext createSecurityContext(WithMockCustomMember annotation) { | ||
SecurityContext context = SecurityContextHolder.createEmptyContext(); | ||
Member member = new Member(annotation.first(),"[email protected]","test","01000000000",null,"",annotation.second(), Gender.MALE); | ||
Collection<GrantedAuthority> authorities = Collections.singleton(new SimpleGrantedAuthority(member.getRole().toString())); | ||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(member.getId(), null, authorities); | ||
context.setAuthentication(authenticationToken); | ||
|
||
return context; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.