-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "impl. Cloudflare Turnstile to client and server"
This reverts commit b733d24.
- Loading branch information
1 parent
df7ee5b
commit 3786bd4
Showing
12 changed files
with
17 additions
and
148 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
28 changes: 0 additions & 28 deletions
28
...in/java/com/kurttekin/can/job_track/application/service/TurnstileVerificationService.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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,4 @@ public JavaMailSender javaMailSender() { | |
|
||
return mailSender; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import com.kurttekin.can.job_track.application.dto.LoginRequest; | ||
import com.kurttekin.can.job_track.application.dto.UserRegistrationRequest; | ||
import com.kurttekin.can.job_track.application.service.EmailService; | ||
import com.kurttekin.can.job_track.application.service.TurnstileVerificationService; | ||
import com.kurttekin.can.job_track.domain.service.UserService; | ||
import com.kurttekin.can.job_track.infrastructure.security.jwt.JwtProvider; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
@@ -49,13 +48,10 @@ class AuthControllerTest { | |
@Mock | ||
private EmailService emailService; | ||
|
||
@Mock | ||
private TurnstileVerificationService turnstileVerificationService; | ||
|
||
private LoginRequest loginRequest; | ||
private UserRegistrationRequest userRegistrationRequest; | ||
private String token; | ||
private String turnstileToken; | ||
|
||
|
||
@BeforeEach | ||
public void setUp() { | ||
|
@@ -64,19 +60,14 @@ public void setUp() { | |
|
||
userRegistrationRequest = new UserRegistrationRequest("testuser", "[email protected]", "testpassword"); | ||
token = "test.jwt.token"; | ||
turnstileToken= "test.jwt.turnstile"; | ||
} | ||
|
||
@Test | ||
public void testLogin_InvalidCredentials() { | ||
// Mock Turnstile verification logic | ||
//when(turnstileVerificationService.verifyToken(anyString())).thenReturn(true); | ||
when(turnstileVerificationService.verifyToken(turnstileToken)).thenReturn(true); | ||
|
||
when(authenticationManager.authenticate(any(UsernamePasswordAuthenticationToken.class))) | ||
.thenThrow(new BadCredentialsException("Invalid credentials")); | ||
|
||
ResponseEntity<?> response = authController.login(loginRequest, turnstileToken); | ||
ResponseEntity<?> response = authController.login(loginRequest); | ||
|
||
assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); | ||
assertEquals("Invalid credentials", response.getBody()); | ||
|
@@ -91,10 +82,8 @@ public void testRegisterUser_Success() { | |
doNothing().when(userService).registerUser(any(UserRegistrationRequest.class)); | ||
doNothing().when(emailService).sendVerificationEmail(anyString(),anyString(), anyString()); // Mock email sending | ||
|
||
when(turnstileVerificationService.verifyToken(turnstileToken)).thenReturn(true); | ||
|
||
// Call the registerUser method in the controller | ||
ResponseEntity<String> response = authController.registerUser(userRegistrationRequest, turnstileToken); | ||
ResponseEntity<String> response = authController.registerUser(userRegistrationRequest); | ||
|
||
// Check the status and response body | ||
assertEquals(HttpStatus.OK, response.getStatusCode()); | ||
|
@@ -105,9 +94,7 @@ public void testRegisterUser_Success() { | |
public void testRegisterUser_Failure() { | ||
doThrow(new RuntimeException("Registration failed")).when(userService).registerUser(any(UserRegistrationRequest.class)); | ||
|
||
when(turnstileVerificationService.verifyToken(turnstileToken)).thenReturn(true); | ||
|
||
ResponseEntity<String> response = authController.registerUser(userRegistrationRequest, turnstileToken); | ||
ResponseEntity<String> response = authController.registerUser(userRegistrationRequest); | ||
|
||
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode()); | ||
assertEquals("Registration failed", response.getBody()); | ||
|
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export const REACT_APP_BACKEND_URL = process.env.REACT_APP_BACKEND_URL+'/api'; | ||
export const REACT_APP_TURNSTILE_SITE_KEY = process.env.REACT_APP_TURNSTILE_SITE_KEY; | ||
export const REACT_APP_BACKEND_URL = process.env.REACT_APP_BACKEND_URL+'/api'; |
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