mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix(xbox): show why Microsoft sign-in fails, and the gamertag instead of the email (#1322)
Sign-in sat on a black "Preparing Microsoft sign-in…" screen while the Xbox components downloaded and the helper started, then only said "did not complete" (#1300). The window now names each step (with download progress), and a failure says which step failed and why. Our own messages are shown as written; anything else is named by its exception type only. The line also goes to the stores log, which the shared log zip carries. The Stores page showed the account's sign-in email. It now shows the Xbox gamertag, read with `xodus-cli profile` after the library sync on its own thread (75 s limit: the command allows itself 45 s, plus PRoot start-up), once per signed-in account. Until it is known the email is shown masked, and only the store label while credentials are temporarily unreadable. The account key used for caches and launches is unchanged. Co-authored-by: xXJsonDeruloXx <danielhimebauch@gmail.com>
This commit is contained in:
1 parent
633f66fd49
commit
58f0f27f39
8 files changed
+175
-6
No files matched your search
@@ -131,6 +131,25 @@ class StoreAccountsCipherTest {
|
||||
assertEquals("test@example.test", StoreAccounts.signedInAs(app, Store.XBOX))
|
||||
}
|
||||
|
||||
@Test fun xboxShowsTheGamertagElseAMaskedEmail() {
|
||||
StoreAccounts.write(app, Store.XBOX, JSONObject().put("username", "player@example.test"))
|
||||
assertEquals("p•••@example.test", StoreAccounts.displayName(app, Store.XBOX))
|
||||
StoreAccounts.write(app, Store.XBOX, JSONObject().put("username", "player@example.test").put("gamertag", "Some Gamertag"))
|
||||
assertEquals("Some Gamertag", StoreAccounts.displayName(app, Store.XBOX))
|
||||
assertEquals("player@example.test", StoreAccounts.signedInAs(app, Store.XBOX))
|
||||
StoreAccounts.write(app, Store.EPIC, creds)
|
||||
assertEquals("Someone", StoreAccounts.displayName(app, Store.EPIC))
|
||||
assertEquals("n•••", StoreAccounts.maskEmail("nickname"))
|
||||
}
|
||||
|
||||
@Test fun xboxDisplayNameDoesNotRevealEmailWhenCredentialsAreTemporarilyUnavailable() {
|
||||
StoreAccounts.write(app, Store.XBOX, JSONObject().put("username", "player@example.test"))
|
||||
StoreAccounts.keys = Flaky(key, 1) { java.security.ProviderException("busy") }
|
||||
assertEquals(Store.XBOX.label, StoreAccounts.displayName(app, Store.XBOX))
|
||||
assertTrue(StoreAccounts.isUnavailable(Store.XBOX))
|
||||
assertTrue(file(Store.XBOX).exists())
|
||||
}
|
||||
|
||||
@Test fun signOutRemovesTheFile() {
|
||||
StoreAccounts.write(app, Store.GOG, creds)
|
||||
StoreAccounts.clear(app, Store.GOG)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.droiddeck.launcher.stores.xbox
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
@org.junit.runner.RunWith(org.robolectric.RobolectricTestRunner::class)
|
||||
@org.robolectric.annotation.Config(sdk = [33], application = android.app.Application::class)
|
||||
class XboxSignInMessagesTest {
|
||||
@Test fun ownCheckMessagesAreShownAndOtherTextIsNot() {
|
||||
assertEquals("the Xbox helper stopped with exit code 3", XboxLoginActivity.failure(IllegalStateException("the Xbox helper stopped with exit code 3")))
|
||||
assertEquals("IllegalStateException", XboxLoginActivity.failure(IllegalStateException("Check failed.")))
|
||||
assertEquals("JSONException", XboxLoginActivity.failure(org.json.JSONException("token=secret-value")))
|
||||
assertEquals("IllegalArgumentException", XboxLoginActivity.failure(IllegalArgumentException("secret-value")))
|
||||
}
|
||||
|
||||
@Test fun gamertagMustBeShortPrintableText() {
|
||||
assertTrue(XboxGamertag.valid("Some Gamertag"))
|
||||
assertFalse(XboxGamertag.valid(""))
|
||||
assertFalse(XboxGamertag.valid("a\nb"))
|
||||
assertFalse(XboxGamertag.valid("x".repeat(65)))
|
||||
}
|
||||
|
||||
@Test fun gamertagRefreshIsOncePerAccountGeneration() {
|
||||
val first = "account-generation-one-${System.nanoTime()}"
|
||||
val second = "account-generation-two-${System.nanoTime()}"
|
||||
assertTrue(XboxGamertag.shouldTryRefresh(first))
|
||||
assertFalse(XboxGamertag.shouldTryRefresh(first))
|
||||
assertTrue(XboxGamertag.shouldTryRefresh(second))
|
||||
assertFalse(XboxGamertag.shouldTryRefresh(second))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user