Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ class AddNewAccountActivityEnterpriseTest : BaseSignActivityTest() {
val mockWebServerRule = FlowCryptMockWebServerRule(TestConstants.MOCK_WEB_SERVER_PORT, object : Dispatcher() {
override fun dispatch(request: RecordedRequest): MockResponse {
val gson = ApiHelper.getInstance(InstrumentationRegistry.getInstrumentation().targetContext).gson
val model = gson.fromJson<LoginModel>(InputStreamReader(request.body.inputStream()),
LoginModel::class.java)
val model = gson.fromJson(InputStreamReader(request.body.inputStream()), LoginModel::class.java)

if (request.path.equals("/account/login")) {
when (model.account) {
EMAIL_WITH_NO_PRV_CREATE_RULE -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LoginResponse(null, isRegistered = true, isVerified = true)))
.setBody(gson.toJson(LoginResponse(null, isVerified = true)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ class SignInActivityEnterpriseTest : BaseSignActivityTest() {
isToastDisplayed(decorView, getResString(R.string.user_not_verified))
}

@Test
@ReadyForCIAnnotation
fun testSuccessLoginNotRegisteredNotVerified() {
setupAndClickSignInButton(genMockGoogleSignInAccountJson(EMAIL_LOGIN_NOT_REGISTERED_NOT_VERIFIED))
isToastDisplayed(decorView, getResString(R.string.user_not_registered_not_verified))
}

@Test
@ReadyForCIAnnotation
fun testErrorGetDomainRules() {
Expand All @@ -113,11 +106,10 @@ class SignInActivityEnterpriseTest : BaseSignActivityTest() {
const val EMAIL_WITH_NO_PRV_CREATE_RULE = "no_prv_create@example.com"
const val EMAIL_LOGIN_ERROR = "login_error@example.com"
const val EMAIL_LOGIN_NOT_VERIFIED = "login_not_verified@example.com"
const val EMAIL_LOGIN_NOT_REGISTERED_NOT_VERIFIED = "login_not_registered_not_verified@example.com"
const val EMAIL_DOMAIN_RULES_ERROR = "domain_rules_error@example.com"

val LOGIN_API_ERROR_RESPONSE = LoginResponse(ApiError(400, "Something wrong happened.",
"api input: missing key: token"), null, null)
"api input: missing key: token"), null)

val DOMAIN_RULES_ERROR_RESPONSE = DomainRulesResponse(ApiError(401,
"Not logged in or unknown account", "auth"), null)
Expand All @@ -134,17 +126,14 @@ class SignInActivityEnterpriseTest : BaseSignActivityTest() {
EMAIL_LOGIN_ERROR -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LOGIN_API_ERROR_RESPONSE))

EMAIL_LOGIN_NOT_REGISTERED_NOT_VERIFIED -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LoginResponse(null, isRegistered = false, isVerified = false)))

EMAIL_LOGIN_NOT_VERIFIED -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LoginResponse(null, isRegistered = true, isVerified = false)))
.setBody(gson.toJson(LoginResponse(null, isVerified = false)))

EMAIL_DOMAIN_RULES_ERROR -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LoginResponse(null, isRegistered = true, isVerified = true)))
.setBody(gson.toJson(LoginResponse(null, isVerified = true)))

EMAIL_WITH_NO_PRV_CREATE_RULE -> return MockResponse().setResponseCode(200)
.setBody(gson.toJson(LoginResponse(null, isRegistered = true, isVerified = true)))
.setBody(gson.toJson(LoginResponse(null, isVerified = true)))
}
}

Expand All @@ -163,4 +152,4 @@ class SignInActivityEnterpriseTest : BaseSignActivityTest() {
}
})
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: DenBond7
* Contributors:
* DenBond7
* Ivan Pizhenko
*/

package com.flowcrypt.email.api.retrofit.response.api
Expand All @@ -22,19 +24,15 @@ import com.google.gson.annotations.SerializedName
*/
data class LoginResponse constructor(@SerializedName("error")
@Expose override val apiError: ApiError?,
@SerializedName("registered")
@Expose val isRegistered: Boolean?,
@SerializedName("verified")
@Expose val isVerified: Boolean?) : ApiResponse {
constructor(parcel: Parcel) : this(
parcel.readParcelable(ApiError::class.java.classLoader),
parcel.readValue(Boolean::class.java.classLoader) as Boolean?,
parcel.readValue(Boolean::class.java.classLoader) as Boolean?)

override fun writeToParcel(parcel: Parcel, flags: Int) {
with(parcel) {
writeParcelable(apiError, flags)
writeValue(isRegistered)
writeValue(isVerified)
}
}
Expand All @@ -52,4 +50,4 @@ data class LoginResponse constructor(@SerializedName("error")
return arrayOfNulls(size)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
* © 2016-present FlowCrypt a.s. Limitations apply. Contact human@flowcrypt.com
* Contributors: DenBond7
* Contributors:
* DenBond7
* Ivan Pizhenko
*/

package com.flowcrypt.email.jetpack.viewmodel
Expand Down Expand Up @@ -49,18 +51,13 @@ class EnterpriseDomainRulesViewModel(application: Application) : BaseAndroidView
}

Result.Status.SUCCESS -> {
if (loginResult.data?.isRegistered == true && loginResult.data.isVerified == true) {
if (loginResult.data?.isVerified == true) {
val domainRulesResult = repository.getDomainRules(context,
DomainRulesRequest(ApiName.POST_GET_DOMAIN_RULES, LoginModel(account, uuid)))
domainRulesLiveData.value = domainRulesResult
} else when {
loginResult.data?.isRegistered == false && loginResult.data.isVerified == false ->
domainRulesLiveData.value = Result.error(LoginResponse(ApiError(-1,
context.getString(R.string.user_not_registered_not_verified)), false, false))

loginResult.data?.isVerified == false ->
domainRulesLiveData.value = Result.error(LoginResponse(ApiError(-1,
context.getString(R.string.user_not_verified)), true, false))
} else {
domainRulesLiveData.value = Result.error(LoginResponse(ApiError(-1,
context.getString(R.string.user_not_verified)), false))
}
}

Expand All @@ -70,4 +67,4 @@ class EnterpriseDomainRulesViewModel(application: Application) : BaseAndroidView
}
}
}
}
}
3 changes: 1 addition & 2 deletions FlowCrypt/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@
<string name="your_email_address">Your email address</string>
<string name="pending">Pending&#8230;</string>
<string name="mark_unread">Mark unread</string>
<string name="user_not_verified">User not verified</string>
<string name="user_not_registered_not_verified">User not registered and not verified</string>
<string name="user_not_verified">User not verified successfully</string>
<string name="submitting_pub_key">Submitting the pub key</string>
<string name="saving_prv_keys">Saving the private key(s)</string>
<string name="key_already_imported_finishing_setup">Key already imported, finishing setup.</string>
Expand Down