aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-30 14:34:10 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-03-30 14:34:10 -0400
commit9fba1c4af3c9b5aad206ec76469c1625125ea799 (patch)
treeb31f52745944cfd6159b6fcef60b19fe4c80a3dc /ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java
parentf23afc7f3b0b62384b3b54a0864b02abc3b48b01 (diff)
parent0c793d302c5065085ff7982a68f7ed449d84d6dc (diff)
downloadJellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.tar.gz
JellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.tar.bz2
JellySolutions-9fba1c4af3c9b5aad206ec76469c1625125ea799.zip
Merge remote-tracking branch 'origin/main' into list-and-cupboard-component-refactor
# Conflicts: # ufund-api/src/main/java/com/ufund/api/ufundapi/controller/CupboardController.java # ufund-api/src/main/java/com/ufund/api/ufundapi/model/Need.java # ufund-ui/src/app/components/cupboard/cupboard.component.ts # ufund-ui/src/app/components/need-list/need-list.component.ts # ufund-ui/src/app/models/Need.ts
Diffstat (limited to 'ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java
index 55cf7a9..4f58b12 100644
--- a/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java
+++ b/ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java
@@ -11,7 +11,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
-import com.ufund.api.ufundapi.DuplicateKeyException;
import com.ufund.api.ufundapi.model.User;
import com.ufund.api.ufundapi.model.UserAuth;
import com.ufund.api.ufundapi.persistence.UserAuthDAO;
@@ -41,39 +40,39 @@ public class AuthServiceTest {
}
@Test
- public void testAuthenticate() throws IOException {
+ public void testKeyIsValid() throws IOException {
// Mock
when(mockAuthDAO.getUserAuth(key)).thenReturn(new UserAuth(key, username, null));
when(mockUserService.getUser(username)).thenReturn(user);
// Analyze
- assertDoesNotThrow(() -> authService.authenticate(username, key));
+ assertDoesNotThrow(() -> authService.keyHasAccessToUser(username, key));
}
-// @Test
-// public void testAuthenticateMismatchName() throws IOException {
-// // Mock
-// when(mockAuthDAO.getUserAuth(key)).thenReturn(new UserAuth(key, "EvilFish", null));
-// when(mockUserService.getUser("EvilFish")).thenReturn(user);
-//
-// // Analyze
-// assertThrows(IllegalAccessException.class, () -> authService.authenticate(username, key));
-//
-// }
+ @Test
+ public void testKeyIsValidMismatchName() throws IOException {
+ // Mock
+ when(mockAuthDAO.getUserAuth(key)).thenReturn(new UserAuth(key, "EvilFish", null));
+ when(mockUserService.getUser("EvilFish")).thenReturn(user);
+
+ // Analyze
+ assertThrows(IllegalAccessException.class, () -> authService.keyHasAccessToUser(username, key));
+
+ }
@Test
- public void testAuthenticateMissingUserAuth() throws IOException {
+ public void testKeyIsValidMissingUserAuth() throws IOException {
// Mock
when(mockAuthDAO.getUserAuth(key)).thenReturn(null);
// Analyze
- assertThrows(IllegalAccessException.class, () -> authService.authenticate(username, key));
+ assertThrows(IllegalAccessException.class, () -> authService.keyHasAccessToUser(username, key));
}
@Test
- public void testLogin() throws IOException, DuplicateKeyException, IllegalAccessException {
+ public void testLogin() throws IOException {
// Mock
when(mockUserService.getUser(username)).thenReturn(user);
@@ -83,7 +82,7 @@ public class AuthServiceTest {
}
@Test
- public void testLoginNullUser() throws IOException, DuplicateKeyException, IllegalAccessException {
+ public void testLoginNullUser() throws IOException {
// Mock
when(mockUserService.getUser(username)).thenReturn(null);
@@ -92,7 +91,7 @@ public class AuthServiceTest {
}
@Test
- public void testLoginMismatchPasswords() throws IOException, DuplicateKeyException, IllegalAccessException {
+ public void testLoginMismatchPasswords() throws IOException {
// Mock
when(mockUserService.getUser(username)).thenReturn(User.create(username, "fries"));
@@ -101,7 +100,7 @@ public class AuthServiceTest {
}
@Test
- public void testLogout() throws IOException, DuplicateKeyException, IllegalAccessException {
+ public void testLogout() {
// Analyze
assertDoesNotThrow(() -> authService.logout(key));