[API] Make support for alternative log addresses more centralized (#52)

This commit is contained in:
Mikołaj Pich
2018-02-26 20:36:45 +01:00
committed by Rafał Borcz
parent f93816910d
commit a1a3427142
12 changed files with 164 additions and 175 deletions

View File

@ -50,7 +50,6 @@ public class FirstAccountLoginTest {
@Test
public void loginTest() throws Exception {
StudentAndParent snp = Mockito.mock(StudentAndParent.class);
Mockito.when(snp.getSymbol()).thenReturn("TEST-SYMBOL");
Mockito.when(snp.getId()).thenReturn("TEST-ID");
PersonalData personalData = Mockito.mock(PersonalData.class);
@ -60,8 +59,9 @@ public class FirstAccountLoginTest {
Mockito.doReturn(personalData).when(basicInformation).getPersonalData();
Vulcan vulcan = Mockito.mock(Vulcan.class);
Mockito.doReturn(basicInformation).when(vulcan).getBasicInformation();
Mockito.doReturn("TEST-SYMBOL").when(vulcan).login(Mockito.anyString(), Mockito.anyString(), Mockito.anyString());
Mockito.doReturn(snp).when(vulcan).getStudentAndParent();
Mockito.doReturn(basicInformation).when(vulcan).getBasicInformation();
FirstAccountLogin firstAccountLogin = new FirstAccountLogin(targetContext, daoSession, vulcan);
LoginSession loginSession = firstAccountLogin.login("TEST@TEST", "TEST-PASS", "default");

View File

@ -33,7 +33,7 @@ public class FirstAccountLogin {
public LoginSession login(String email, String password, String symbol)
throws NotLoggedInErrorException, AccountPermissionException, IOException, CryptoException, VulcanOfflineException, BadCredentialsException {
vulcan.login(email, password, symbol);
String realSymbol = vulcan.login(email, password, symbol);
AccountDao accountDao = daoSession.getAccountDao();
Safety safety = new Safety();
@ -41,7 +41,7 @@ public class FirstAccountLogin {
.setName(vulcan.getBasicInformation().getPersonalData().getFirstAndLastName())
.setEmail(email)
.setPassword(safety.encrypt(email, password, context))
.setSymbol(vulcan.getStudentAndParent().getSymbol())
.setSymbol(realSymbol)
.setSnpId(vulcan.getStudentAndParent().getId());
long userId = accountDao.insert(account);