Skip to content

Commit

Permalink
Handled a situation of sign-in users(gmail.com) in the enterprise bui…
Browse files Browse the repository at this point in the history
…ld.| #2162
  • Loading branch information
DenBond7 committed Mar 8, 2023
1 parent 0786af1 commit b47043d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,32 @@ class FesDuringSetupEnterpriseFlowTest : BaseFesDuringSetupFlowTest() {
.check(matches(isDisplayed()))
}

@Test
fun testFlowForPublicEmailDomainsGmail() {
setupAndClickSignInButton(genMockGoogleSignInAccountJson(EMAIL_GMAIL))
isDialogWithTextDisplayed(
decorView,
getResString(
R.string.enterprise_does_not_support_pub_domains,
getResString(R.string.app_name),
"gmail.com"
)
)
}

@Test
fun testFlowForPublicEmailDomainsGoogleMail() {
setupAndClickSignInButton(genMockGoogleSignInAccountJson(EMAIL_GOOGLEMAIL))
isDialogWithTextDisplayed(
decorView,
getResString(
R.string.enterprise_does_not_support_pub_domains,
getResString(R.string.app_name),
"googlemail.com"
)
)
}

private fun handleEkmAPI(request: RecordedRequest, gson: Gson): MockResponse {
return when {
request.path.equals("/ekm/v1/keys/private") ->
Expand All @@ -212,6 +238,9 @@ class FesDuringSetupEnterpriseFlowTest : BaseFesDuringSetupFlowTest() {
private const val EMAIL_FES_SUCCESS = "[email protected]"
private const val EMAIL_FES_SSL_ERROR = "[email protected]"

private const val EMAIL_GMAIL = "[email protected]"
private const val EMAIL_GOOGLEMAIL = "[email protected]"

private val ACCEPTED_FLAGS = listOf(
ClientConfiguration.ConfigurationProperty.PRV_AUTOIMPORT_OR_AUTOGEN,
ClientConfiguration.ConfigurationProperty.FORBID_STORING_PASS_PHRASE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,22 @@ class MainSignInFragment : BaseSingInFragment<FragmentMainSignInBinding>() {
cachedBaseFesUrlPath = GeneralUtil.genBaseFesUrlPath(useCustomerFesUrl = false)

val publicEmailDomains = EmailUtil.getPublicEmailDomains()
if (EmailUtil.getDomain(account) in publicEmailDomains) {
onSignSuccess(cachedGoogleSignInAccount)
val domain = EmailUtil.getDomain(account)
if (domain in publicEmailDomains) {
if (BuildConfig.FLAVOR == Constants.FLAVOR_NAME_ENTERPRISE) {
cachedGoogleSignInAccount = null
showInfoDialog(
dialogTitle = "",
dialogMsg = getString(
R.string.enterprise_does_not_support_pub_domains,
getString(R.string.app_name),
domain
),
isCancelable = true
)
} else {
onSignSuccess(cachedGoogleSignInAccount)
}
} else {
checkCustomerUrlFesServerViewModel.checkServerAvailability(account)
}
Expand Down
1 change: 1 addition & 0 deletions FlowCrypt/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@
<string name="fes_server_has_wrong_settings">Ваш FES сервер настроен неверно. Пожалуйста, обратитесь в службу поддержки.</string>
<string name="check_fes_error_with_retry">Произошла ошибка.\nПодробности:%1$s\n\nПожалуйста, попробуйте еще раз.</string>
<string name="fes_server_error">Ошибка сервера:%1$s</string>
<string name="enterprise_does_not_support_pub_domains">Эта версия %1$s не может быть использована с доменом %2$s. Если Вы установили это приложение случайно, пожалуйста, установите некорпоративную версию %1$s.</string>
<plurals name="found_backup_of_your_account_key">
<item quantity="one">Найдена %1$d резервная копия Вашего ключа</item>
<item quantity="few">Найдено %1$d резервные копии Вашего ключа</item>
Expand Down
1 change: 1 addition & 0 deletions FlowCrypt/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@
<string name="fes_server_has_wrong_settings">Ваш FES сервер налаштований не вірно. Будь ласка, зверніться до служби підтримки.</string>
<string name="check_fes_error_with_retry">Виникла помилка.\nДеталі:%1$s\n\nБудь ласка, спробуйте ще раз.</string>
<string name="fes_server_error">Помилка сервера:%1$s</string>
<string name="enterprise_does_not_support_pub_domains">Ця версія %1$s не може бути використана з доменом %2$s. Якщо Ви встановили це додаток випадково, будь ласка, встановіть некорпоративну версію %1$s.</string>
<plurals name="found_backup_of_your_account_key">
<item quantity="one">Знайдена %1$d резервна копія Вашого ключа</item>
<item quantity="few">Знайдено %1$d резервні копії Вашого ключа</item>
Expand Down
1 change: 1 addition & 0 deletions FlowCrypt/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,5 @@
<string name="fes_server_has_wrong_settings">Your FES server has the wrong settings. Please ask your help desk for help.</string>
<string name="check_fes_error_with_retry">An error occurred.\nDetails:%1$s\n\nPlease try again.</string>
<string name="fes_server_error">Server error:%1$s</string>
<string name="enterprise_does_not_support_pub_domains">This version of %1$s cannot be used on %2$s domain. If you installed this app by accident, please install non-enterprise FlowCrypt app.</string>
</resources>

0 comments on commit b47043d

Please sign in to comment.