From 11d82c6ee994666cdf4a6665e5901980a7d69065 Mon Sep 17 00:00:00 2001
From: CONGRANLI <907112284@qq.com>
Date: Fri, 6 Sep 2019 02:26:19 +1000
Subject: [PATCH] recover
---
.../swen90006/passbook/BoundaryTests.java | 5 +
.../swen90006/passbook/PartitioningTests.java | 185 ++++++++++++++++--
2 files changed, 178 insertions(+), 12 deletions(-)
diff --git a/tests/Boundary/swen90006/passbook/BoundaryTests.java b/tests/Boundary/swen90006/passbook/BoundaryTests.java
index 7b0c52d..fb9482b 100755
--- a/tests/Boundary/swen90006/passbook/BoundaryTests.java
+++ b/tests/Boundary/swen90006/passbook/BoundaryTests.java
@@ -41,6 +41,11 @@ public class BoundaryTests
assertFalse(WeakPassphraseException);
}
+ @Test public void ASCII() {
+ boolean WeakPassphraseException = false;
+
+ }
+
}
diff --git a/tests/Partitioning/swen90006/passbook/PartitioningTests.java b/tests/Partitioning/swen90006/passbook/PartitioningTests.java
index 3747384..c8c82c6 100755
--- a/tests/Partitioning/swen90006/passbook/PartitioningTests.java
+++ b/tests/Partitioning/swen90006/passbook/PartitioningTests.java
@@ -76,7 +76,7 @@ public class PartitioningTests
@Test public void WeakPassphraseException() throws DuplicateUserException{
boolean WeakPassphraseException = false;
String passbookUsername = "AlexTina";
- String passbookphrase = "Ab23333";
+ String passbookphrase = "Ab23";
try{
pb.addUser(passbookUsername,passbookphrase);
}
@@ -114,9 +114,72 @@ public class PartitioningTests
assertFalse(WeakPassphraseException);
}
-
+ // passphrase.length = 8 && passphrase only contain one kind factory in Lower, Upper and Number
- // passphrase.length >= 8 && passphrase not fit the requirement
+ @Test public void Contains() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "AAAABBBC";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertTrue(WeakPassphraseException);
+ }
+
+ // passphrase.length = 8 && passphrase only contain two kind factory in Lower, Upper and Number
+
+ @Test public void Contains2() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "AAA2232C";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertTrue(WeakPassphraseException);
+ }
+
+ // passphrase.length = 8 && passphrase contain no kind factory in Lower, Upper and Number
+
+ @Test public void Contains3() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "^&*($%@#";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertTrue(WeakPassphraseException);
+ }
+
+ // passphrase.length = 8 && passphrase contain all kinds factory in Lower, Upper and Number
+
+ @Test public void Contains4() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "Ab23cd54";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertFalse(WeakPassphraseException);
+ }
+
+
+ // passphrase.length > 8 && passphrase only contain one kind factory in Lower, Upper and Number
@Test public void Contains5() throws DuplicateUserException
{
@@ -132,10 +195,41 @@ public class PartitioningTests
assertTrue(WeakPassphraseException);
}
-
- // passphrase.length >= 8 && passphrase contain all kinds factory in Lower, Upper and Number
+ // passphrase.length > 8 && passphrase only contain two kind factory in Lower, Upper and Number
@Test public void Contains6() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "AAA223293289312C";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertTrue(WeakPassphraseException);
+ }
+
+ // passphrase.length > 8 && passphrase contain no kind factory in Lower, Upper and Number
+
+ @Test public void Contains7() throws DuplicateUserException
+ {
+ boolean WeakPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "^&*($%@#%^&*(";
+ try{
+ pb.addUser(passbookUsername,passbookphrase);
+ }
+ catch (WeakPassphraseException e){
+ WeakPassphraseException = true;
+ }
+ assertTrue(WeakPassphraseException);
+ }
+
+ // passphrase.length > 8 && passphrase contain all kinds factory in Lower, Upper and Number
+
+ @Test public void Contains8() throws DuplicateUserException
{
boolean WeakPassphraseException = false;
String passbookUsername = "AlexTina";
@@ -183,7 +277,22 @@ public class PartitioningTests
assertTrue(NoSuchUserException);
}
-
+ // username is NULL
+ @Test public void NoSuchUserException3() throws NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, WeakPassphraseException, DuplicateUserException {
+ boolean NoSuchUserException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "Abc234hg";
+ String passbookUsername2 = "";
+ String passbookphrase2 = "Abc234hg";
+ try {
+ pb.addUser(passbookUsername,passbookphrase);
+ pb.loginUser(passbookUsername2,passbookphrase2);
+ }
+ catch (NoSuchUserException e){
+ NoSuchUserException = true;
+ }
+ assertTrue(NoSuchUserException);
+ }
// user has login
@Test public void AlreadyLoggedInException() throws NoSuchUserException, IncorrectPassphraseException, WeakPassphraseException, DuplicateUserException {
boolean AlreadyLoggedInException = false;
@@ -213,7 +322,7 @@ public class PartitioningTests
pb.loginUser(passbookUsername,passbookphrase);
-
+
}
catch (AlreadyLoggedInException e){
@@ -255,7 +364,22 @@ public class PartitioningTests
}
assertFalse(IncorrectPassphraseException);
}
-
+ //passphrase is NULL
+ @Test public void IncorrectPassphraseException3() throws WeakPassphraseException, DuplicateUserException, AlreadyLoggedInException, IncorrectPassphraseException, NoSuchUserException {
+ boolean IncorrectPassphraseException = false;
+ String passbookUsername = "AlexTina";
+ String passbookphrase = "Abc234hg";
+ String passbookUsername2 = "AlexTina";
+ String passbookphrase2 = "";
+ try {
+ pb.addUser(passbookUsername,passbookphrase);
+ pb.loginUser(passbookUsername2,passbookphrase2);
+ }
+ catch (IncorrectPassphraseException e){
+ IncorrectPassphraseException = true;
+ }
+ assertTrue(IncorrectPassphraseException);
+ }
//------------------------------updateDetails Test Cases-------------------------------------
@@ -366,7 +490,7 @@ public class PartitioningTests
assertFalse(NoSuchUserException);
}
- //!(urlUsername =! null || urlPassword !=null)
+ //urlUsername = null || urlPassword !=null
@Test public void checkRemove2() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException {
boolean NoSuchUserException = false;
Integer sessionID ;
@@ -386,7 +510,46 @@ public class PartitioningTests
}
assertTrue(NoSuchUserException);
}
-
+ //urlUsername != null || urlPassword =null
+ @Test public void checkRemove3() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException {
+ boolean NoSuchUserException = false;
+ Integer sessionID ;
+ String Username = "AlexTina";
+ String Password = "Abc234hg";
+ String urlUsername = "AlexTina";
+ String urlPassword = null;
+ pb.addUser(Username,Password);
+ sessionID = pb.loginUser(Username,Password);
+ try{
+ URL url = new URL ("http:AlexTinaAbc234hg");
+ pb.updateDetails(sessionID,url,urlUsername,urlPassword);
+ pb.retrieveDetails(sessionID,url);
+ }
+ catch (NoSuchURLException e){
+ NoSuchUserException = true;
+ }
+ assertTrue(NoSuchUserException);
+ }
+ //urlUsername != null || urlPassword !=null
+ @Test public void checkRemove4() throws WeakPassphraseException, DuplicateUserException, NoSuchUserException, AlreadyLoggedInException, IncorrectPassphraseException, InvalidSessionIDException, MalformedURLException, NoSuchURLException {
+ boolean NoSuchUserException = false;
+ Integer sessionID ;
+ String Username = "AlexTina";
+ String Password = "Abc234hg";
+ String urlUsername = null;
+ String urlPassword = null;
+ pb.addUser(Username,Password);
+ sessionID = pb.loginUser(Username,Password);
+ try{
+ URL url = new URL ("http:AlexTinaAbc234hg");
+ pb.updateDetails(sessionID,url,urlUsername,urlPassword);
+ pb.retrieveDetails(sessionID,url);
+ }
+ catch (NoSuchURLException e){
+ NoSuchUserException = true;
+ }
+ assertTrue(NoSuchUserException);
+ }
//------------------------------retrieveDetails Test Cases-------------------------------------
//InvalidSessionIDException
@@ -522,6 +685,4 @@ public class PartitioningTests
-
-
}
--
GitLab