-
Notifications
You must be signed in to change notification settings - Fork 330
login: Reject earlier (at get-server-settings) when server is too old #1783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
login: Reject earlier (at get-server-settings) when server is too old #1783
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this! Looks good; small comments.
import '../api/core.dart'; | ||
import '../api/exception.dart'; | ||
import '../api/model/initial_snapshot.dart'; | ||
import '../api/route/realm.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: third commit removes this line; second commit could omit adding it
connection.prepare(json: serverSettings.toJson()); | ||
await tester.tap(find.text('Continue')); | ||
await tester.pump(Duration.zero); | ||
checkNoDialog(tester); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
third commit has an error at this line
test/widgets/login_test.dart
Outdated
await tester.pump((pushedRoute as TransitionRoute).transitionDuration); | ||
await tester.pump(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this do the job?
await tester.pump((pushedRoute as TransitionRoute).transitionDuration); | |
await tester.pump(); | |
await testNavObserver.pumpPastTransition(tester); |
(Then also pushedRoute above can be inlined.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, TIL we made TestNavigatorObserver
extend TransitionDurationObserver
:) in d7fac5d
test/widgets/login_test.dart
Outdated
testBinding.globalStore.useCachedApiConnections = true; | ||
connection = testBinding.globalStore.apiConnection( | ||
realmUrl: serverSettings.realmUrl, | ||
zulipFeatureLevel: null); | ||
|
||
await tester.enterText(find.byType(TextField), | ||
serverSettings.realmUrl.toString()); | ||
|
||
connection.prepare(json: serverSettings.toJson()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the making an API connection (to go into the global cache), and then preparing a response, go logically together and separate from the entering text into the input.
So like:
testBinding.globalStore.useCachedApiConnections = true; | |
connection = testBinding.globalStore.apiConnection( | |
realmUrl: serverSettings.realmUrl, | |
zulipFeatureLevel: null); | |
await tester.enterText(find.byType(TextField), | |
serverSettings.realmUrl.toString()); | |
connection.prepare(json: serverSettings.toJson()); | |
await tester.enterText(find.byType(TextField), | |
serverSettings.realmUrl.toString()); | |
testBinding.globalStore.useCachedApiConnections = true; | |
connection = testBinding.globalStore.apiConnection( | |
realmUrl: serverSettings.realmUrl, | |
zulipFeatureLevel: null); | |
connection.prepare(json: serverSettings.toJson()); |
Looks like this slipped through CI, introduced recently in 8d3c128.
10e5f91
to
96f59ba
Compare
Thanks, revision pushed! PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! One remaining comment.
test/widgets/login_test.dart
Outdated
testBinding.globalStore.useCachedApiConnections = true; | ||
connection = testBinding.globalStore.apiConnection( | ||
realmUrl: serverSettings.realmUrl, | ||
zulipFeatureLevel: null); | ||
|
||
await tester.enterText(find.byType(TextField), | ||
serverSettings.realmUrl.toString()); | ||
|
||
connection.prepare(json: serverSettings.toJson()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump #1783 (comment) 🙂
Also I suspect this group of tests would be clarified by a little helper. Something like:
await attempt(tester, serverSettings.realmUrl, serverSettings.toJson());
which would cover all these lines and the tap/pump below, and leave the caller to finish up with just the check steps.
@@ -7,7 +7,6 @@ import 'package:url_launcher/url_launcher.dart'; | |||
import 'package:zulip/model/settings.dart'; | |||
import 'package:zulip/widgets/app.dart'; | |||
import 'package:zulip/widgets/dialog.dart'; | |||
import 'package:zulip/widgets/store.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dialog test [nfc]: Remove an unused import
Looks like this slipped through CI, introduced recently in
8d3c1284e.
Ah, oops. I guess that changed in your revision of #1782, and I merged before CI finished running.
… In fact I'm pretty sure I ran flutter test
on this very file before merging, because I saw CI wasn't done. But I guess I should have checked the analyzer output too.
96f59ba
to
73be315
Compare
Thanks, revision pushed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just nits below; otherwise all looks good.
await testNavObserver.pumpPastTransition(tester); | ||
} | ||
|
||
Future<void> attempt(WidgetTester tester, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/widgets/login_test.dart
Outdated
.throws<void>(); | ||
|
||
|
||
await attempt(tester, serverSettings.realmUrl, serverSettingsMalformedJson); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: double blank line
Thanks, fixed! |
There's a planned change to make zulipMergeBase required in GetServerSettingsResult (see zulip#904). When we do that, we'd otherwise just treat a missing zulipMergeBase on an ancient server the same way we treat any malformed response. Better to check if the server is an ancient one we don't support, just like when the /register response is malformed.
73be315
to
733bb88
Compare
Thanks! Looks good; merging. |
See "Feature level 88" from Zulip API changelog: https://zulip.com/api/changelog This is one of the few places (along with registerQueue) where it's important that we smoothly handle attempting to connect to an ancient server where this field might indeed be missing. Happily, we do handle those since commit 733bb88 (zulip#1783).
Stacked atop #1782, which is an improvement to the tests that I found while working this (actually while pairing with @sm-sayedi 🙂) plus a fix for something we overlooked in #1017.
There's a planned change to make zulipMergeBase required in
GetServerSettingsResult (see #904). When we do that, we'd otherwise
just treat a missing zulipMergeBase on an ancient server the same
way we treat any malformed response. Better to check if the server
is an ancient one we don't support, just like when the /register
response is malformed.