aboutsummaryrefslogtreecommitdiff
path: root/ufund-api
diff options
context:
space:
mode:
authorAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-04-08 00:52:51 -0400
committerAkash Keshav <112591754+domesticchores@users.noreply.github.com>2025-04-08 00:52:51 -0400
commitb45f391bf999c2ffc32890072b9fdbbb1dcfeef3 (patch)
tree58055cc6e13266738e5f671688cda1477bde1049 /ufund-api
parent78e9791da675783124c76a20f756886005ffa904 (diff)
parentaf7fbe2837df4cac76383014191e805389da57a2 (diff)
downloadJellySolutions-b45f391bf999c2ffc32890072b9fdbbb1dcfeef3.tar.gz
JellySolutions-b45f391bf999c2ffc32890072b9fdbbb1dcfeef3.tar.bz2
JellySolutions-b45f391bf999c2ffc32890072b9fdbbb1dcfeef3.zip
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b-jellysolutions
Diffstat (limited to 'ufund-api')
-rw-r--r--ufund-api/src/test/java/com/ufund/api/ufundapi/service/AuthServiceTest.java31
1 files changed, 30 insertions, 1 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 4f58b12..db849f2 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
@@ -6,6 +6,8 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.io.IOException;
+import java.time.LocalDateTime;
+import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
@@ -105,5 +107,32 @@ public class AuthServiceTest {
assertDoesNotThrow(() -> authService.logout(key));
}
-
+
+ @Test
+ void keyIsValid() throws IOException {
+ String key = "sowgro";
+ when(mockAuthDAO.getUserAuth(key)).thenReturn(null);
+
+ assertThrows(IllegalAccessException.class, () -> authService.keyIsValid(key));
+ }
+
+ @Test
+ void keyHasAccessToCupboard1() throws IOException {
+ String key = "sowgro";
+ when(mockAuthDAO.getUserAuth(key)).thenReturn(null);
+
+ assertThrows(IllegalAccessException.class, () -> authService.keyHasAccessToCupboard(key));
+ }
+
+ @Test
+ void keyHasAccessToCupboard2() throws IOException {
+ String key = "sowgro";
+ UserAuth userAuth = new UserAuth("sowgro", "sowgro", LocalDateTime.MAX);
+ User user = new User("sowgro", 8675309, List.of(), User.UserType.HELPER);
+
+ when(mockAuthDAO.getUserAuth(key)).thenReturn(userAuth);
+ when(mockUserService.getUser(key)).thenReturn(user);
+
+ assertThrows(IllegalAccessException.class, () -> authService.keyHasAccessToCupboard(key));
+ }
}