This repository has been archived by the owner on Apr 24, 2022. It is now read-only.
forked from TEAMMATES/teammates
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEAMMATES#11655] Devise a better way to handle duplicate account req…
…uests (TEAMMATES#11657)
- Loading branch information
1 parent
489106f
commit cafe194
Showing
39 changed files
with
1,317 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.attributes.AccountRequestAttributes; | ||
import teammates.common.util.AppUrl; | ||
import teammates.common.util.Const; | ||
import teammates.e2e.pageobjects.AdminHomePage; | ||
|
@@ -13,7 +14,8 @@ public class AdminHomePageE2ETest extends BaseE2ETestCase { | |
|
||
@Override | ||
protected void prepareTestData() { | ||
// no test data used in this test | ||
testData = loadDataBundle("/AdminHomePageE2ETest.json"); | ||
removeAndRestoreDataBundle(testData); | ||
} | ||
|
||
@Test | ||
|
@@ -22,6 +24,8 @@ public void testAll() { | |
AppUrl url = createFrontendUrl(Const.WebPageURIs.ADMIN_HOME_PAGE); | ||
AdminHomePage homePage = loginAdminToPage(url, AdminHomePage.class); | ||
|
||
______TS("Test adding instructors with both valid and invalid details"); | ||
|
||
String name = "AHPUiT Instrúctör WithPlusInEmail"; | ||
String email = "[email protected]"; | ||
String institute = "TEAMMATES Test Institute 1"; | ||
|
@@ -44,6 +48,28 @@ public void testAll() { | |
|
||
assertNotNull(BACKDOOR.getAccountRequest(email, institute)); | ||
BACKDOOR.deleteAccountRequest(email, institute); | ||
|
||
______TS("Failure case: Instructor is already registered"); | ||
AccountRequestAttributes registeredAccountRequest = testData.accountRequests.get("AHome.instructor1OfCourse1"); | ||
homePage.queueInstructorForAdding(registeredAccountRequest.getName(), | ||
registeredAccountRequest.getEmail(), registeredAccountRequest.getInstitute()); | ||
|
||
homePage.addAllInstructors(); | ||
|
||
failureMessage = homePage.getMessageForInstructor(2); | ||
assertTrue(failureMessage.contains("Cannot create account request as instructor has already registered.")); | ||
|
||
______TS("Success case: Reset account request"); | ||
|
||
homePage.clickMoreInfoButtonForRegisteredInstructor(2); | ||
homePage.clickResetAccountRequestLink(); | ||
|
||
successMessage = homePage.getMessageForInstructor(2); | ||
assertTrue(successMessage.contains( | ||
"Instructor \"" + registeredAccountRequest.getName() + "\" has been successfully created")); | ||
|
||
assertNull(BACKDOOR.getAccountRequest( | ||
registeredAccountRequest.getEmail(), registeredAccountRequest.getInstitute()).getRegisteredAt()); | ||
} | ||
|
||
} |
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
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,55 @@ | ||
{ | ||
"accounts": { | ||
"AHome.instructor1OfCourse1": { | ||
"googleId": "tm.e2e.AHome.inst1", | ||
"name": "Teammates Instr1", | ||
"isInstructor": true, | ||
"email": "[email protected]", | ||
"institute": "TEAMMATES Test Institute 1" | ||
} | ||
}, | ||
"accountRequests": { | ||
"AHome.instructor1OfCourse1": { | ||
"name": "Teammates Instr1", | ||
"email": "[email protected]", | ||
"institute": "TEAMMATES Test Institute 1", | ||
"createdAt": "2011-01-01T00:00:00Z", | ||
"registeredAt": "1970-02-14T00:00:00Z" | ||
} | ||
}, | ||
"courses": { | ||
"AHome.typicalCourse1": { | ||
"createdAt": "2012-03-20T23:59:00Z", | ||
"id": "tm.e2e.AHome.course1", | ||
"name": "Typical Course 1", | ||
"institute": "TEAMMATES Test Institute 1", | ||
"timeZone": "Africa/Johannesburg" | ||
} | ||
}, | ||
"instructors": { | ||
"AHome.instructor1OfCourse1": { | ||
"googleId": "tm.e2e.AHome.inst1", | ||
"courseId": "tm.e2e.AHome.course1", | ||
"name": "Teammates Instr1", | ||
"email": "[email protected]", | ||
"isArchived": false, | ||
"role": "Co-owner", | ||
"isDisplayedToStudents": true, | ||
"displayedName": "Instructor", | ||
"privileges": { | ||
"courseLevel": { | ||
"canModifyCourse": true, | ||
"canModifyInstructor": true, | ||
"canModifySession": true, | ||
"canModifyStudent": true, | ||
"canViewStudentInSections": true, | ||
"canViewSessionInSections": true, | ||
"canSubmitSessionInSections": true, | ||
"canModifySessionCommentsInSections": true | ||
}, | ||
"sectionLevel": {}, | ||
"sessionLevel": {} | ||
} | ||
} | ||
} | ||
} |
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
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
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,23 @@ | ||
package teammates.ui.output; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import teammates.common.datatransfer.attributes.AccountAttributes; | ||
|
||
/** | ||
* The API output format of a list of accounts. | ||
*/ | ||
public class AccountsData extends ApiOutput { | ||
|
||
private List<AccountData> accounts; | ||
|
||
public AccountsData(List<AccountAttributes> accountAttributes) { | ||
this.accounts = accountAttributes.stream().map(AccountData::new).collect(Collectors.toList()); | ||
} | ||
|
||
public List<AccountData> getAccounts() { | ||
return accounts; | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package teammates.ui.webapi; | ||
|
||
import java.util.List; | ||
|
||
import teammates.common.datatransfer.attributes.AccountAttributes; | ||
import teammates.common.util.Const; | ||
import teammates.common.util.SanitizationHelper; | ||
import teammates.ui.output.AccountsData; | ||
|
||
/** | ||
* Gets all accounts with the given email. | ||
*/ | ||
class GetAccountsAction extends AdminOnlyAction { | ||
|
||
@Override | ||
public JsonResult execute() { | ||
String email = getNonNullRequestParamValue(Const.ParamsNames.USER_EMAIL); | ||
email = SanitizationHelper.sanitizeEmail(email); | ||
|
||
List<AccountAttributes> accounts = logic.getAccountsForEmail(email); | ||
|
||
return new JsonResult(new AccountsData(accounts)); | ||
} | ||
|
||
} |
Oops, something went wrong.