-
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.
- Loading branch information
Showing
33 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Donation.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
2 changes: 2 additions & 0 deletions
2
helpmehelpapplication/src/main/java/ntnu/sytemutvikling/team6/models/Feedback.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
2 changes: 1 addition & 1 deletion
2
...nu/sytemutvikling/team6/models/Inbox.java → ...temutvikling/team6/models/user/Inbox.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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
| package ntnu.sytemutvikling.team6.models.user; | ||
|
|
||
| import java.util.*; | ||
|
|
||
|
|
||
2 changes: 1 addition & 1 deletion
2
...sytemutvikling/team6/models/Language.java → ...utvikling/team6/models/user/Language.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
2 changes: 1 addition & 1 deletion
2
.../sytemutvikling/team6/models/Message.java → ...mutvikling/team6/models/user/Message.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
2 changes: 1 addition & 1 deletion
2
...tnu/sytemutvikling/team6/models/Role.java → ...ytemutvikling/team6/models/user/Role.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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package ntnu.sytemutvikling.team6.models; | ||
| package ntnu.sytemutvikling.team6.models.user; | ||
|
|
||
| /** | ||
| * Available users | ||
|
|
||
2 changes: 1 addition & 1 deletion
2
...sytemutvikling/team6/models/Settings.java → ...utvikling/team6/models/user/Settings.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
4 changes: 3 additions & 1 deletion
4
...tnu/sytemutvikling/team6/models/User.java → ...ytemutvikling/team6/models/user/User.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
2 changes: 1 addition & 1 deletion
2
...tvikling/team6/models/PasswordHasher.java → ...ikling/team6/security/PasswordHasher.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
70 changes: 70 additions & 0 deletions
70
...ehelpapplication/src/test/java/ntnu/sytemutvikling/team6/security/PasswordHasherTest.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,70 @@ | ||
| package ntnu.sytemutvikling.team6.security; | ||
|
|
||
| import org.junit.jupiter.api.Nested; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class PasswordHasherTest { | ||
| private final PasswordHasher hasher = new PasswordHasher(); | ||
|
|
||
| @Nested | ||
| class getHashPasswordTest { | ||
|
|
||
| @Test | ||
| void shouldThrowIfPasswordIsNull() { | ||
| assertThrows(IllegalArgumentException.class, () -> hasher.getHashPassword(null)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldThrowIfPasswordIsBlank() { | ||
| assertThrows(IllegalArgumentException.class, () -> hasher.getHashPassword(" ")); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnDifferentHashesForSamePasswordBecauseSaltIsRandom() { | ||
| String test1 = hasher.getHashPassword("Password"); | ||
| String test2 = hasher.getHashPassword("Password"); | ||
|
|
||
| assertNotEquals(test1, test2); | ||
| } | ||
| } | ||
|
|
||
| @Nested | ||
| class isValidPasswordTest { | ||
|
|
||
| @Test | ||
| void shouldReturnTrueForCorrectPassword() { | ||
| String test = hasher.getHashPassword("Password"); | ||
| assertTrue(hasher.isValidPassword("Password", test)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnFalseForWrongPassword() { | ||
| String test = hasher.getHashPassword("Password"); | ||
| assertFalse(hasher.isValidPassword("password", test)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnFalseIfPasswordIsBlank() { | ||
| String test = hasher.getHashPassword("Test"); | ||
| assertFalse(hasher.isValidPassword(" ", test)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldReturnFalseIfPasswordIsNull() { | ||
| String test = hasher.getHashPassword("Test"); | ||
| assertFalse(hasher.isValidPassword(null, test)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldThrowIfStoredHashIsNull() { | ||
| assertThrows(RuntimeException.class, () -> hasher.isValidPassword("Password", null)); | ||
| } | ||
|
|
||
| @Test | ||
| void shouldThrowIfStoredHashIsBlank() { | ||
| assertThrows(RuntimeException.class, () -> hasher.isValidPassword("Password", " ")); | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+568 Bytes
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/Main.class
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Charity.class
Binary file not shown.
Binary file modified
BIN
+44 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/CharityRegistry.class
Binary file not shown.
Binary file modified
BIN
+26 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Donation.class
Binary file not shown.
Binary file modified
BIN
+46 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/DonationRegistry.class
Binary file not shown.
Binary file modified
BIN
+26 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Feedback.class
Binary file not shown.
Binary file removed
BIN
-2.81 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Inbox.class
Binary file not shown.
Binary file removed
BIN
-1.02 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Language.class
Binary file not shown.
Binary file removed
BIN
-1.51 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Message.class
Binary file not shown.
Binary file removed
BIN
-1.05 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Role.class
Binary file not shown.
Binary file removed
BIN
-1.55 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/Settings.class
Binary file not shown.
Binary file removed
BIN
-1.75 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/User.class
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/UserRegistry.class
Binary file not shown.
Binary file added
BIN
+2.9 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/Inbox.class
Binary file not shown.
Binary file added
BIN
+1.12 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/Language.class
Binary file not shown.
Binary file added
BIN
+1.52 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/Message.class
Binary file not shown.
Binary file added
BIN
+1.15 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/Role.class
Binary file not shown.
Binary file added
BIN
+1.59 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/Settings.class
Binary file not shown.
Binary file added
BIN
+2.27 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/models/user/User.class
Binary file not shown.
Binary file added
BIN
+2.71 KB
helpmehelpapplication/target/classes/ntnu/sytemutvikling/team6/security/PasswordHasher.class
Binary file not shown.
Binary file added
BIN
+2.66 KB
...t-classes/ntnu/sytemutvikling/team6/security/PasswordHasherTest$getHashPasswordTest.class
Binary file not shown.
Binary file added
BIN
+3.14 KB
...t-classes/ntnu/sytemutvikling/team6/security/PasswordHasherTest$isValidPasswordTest.class
Binary file not shown.
Binary file added
BIN
+772 Bytes
...plication/target/test-classes/ntnu/sytemutvikling/team6/security/PasswordHasherTest.class
Binary file not shown.