Skip to content

Commit c1d6489

Browse files
committed
test(mobile): drop org key backup checks from the #9069 backport
0.27 has no organization key backup (#9029), so the backported organization relay tests keep their assertion and cache checks only. Signed-off-by: Tom Brow <[email protected]>
1 parent 7db5cee commit c1d6489

1 file changed

Lines changed: 17 additions & 38 deletions

File tree

‎mobile/test/shared/hosted/organization_relay_auth_test.dart‎

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:buzz/shared/hosted/browser_auth.dart';
55
import 'package:buzz/shared/hosted/builderlab_account.dart';
66
import 'package:buzz/shared/hosted/hosted_relay_auth.dart';
77
import 'package:buzz/shared/hosted/organization_environment.dart';
8-
import 'package:buzz/shared/hosted/organization_key_backup.dart';
98
import 'package:buzz/shared/hosted/organization_sign_in.dart';
109
import 'package:buzz/shared/relay/relay_provider.dart';
1110
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@@ -141,21 +140,20 @@ void main() {
141140
}),
142141
);
143142

144-
HostedRelayAuth relayAuth(
145-
BuilderlabAccountClient organizationAccount, {
146-
OrganizationKeyBackup? backup,
147-
}) => HostedRelayAuth(
148-
BuilderlabAccountClient(
149-
httpClient: MockClient(
150-
(request) async => fail('Hosted account must not be used'),
151-
),
152-
),
153-
organization: organizationAccount,
154-
organizationBackup: backup,
155-
organizationRelay: (relay) =>
156-
OrganizationEnvironment.matches(relay, [relayHost, otherRelayHost]),
157-
enabled: true,
158-
);
143+
HostedRelayAuth relayAuth(BuilderlabAccountClient organizationAccount) =>
144+
HostedRelayAuth(
145+
BuilderlabAccountClient(
146+
httpClient: MockClient(
147+
(request) async => fail('Hosted account must not be used'),
148+
),
149+
),
150+
organization: organizationAccount,
151+
organizationRelay: (relay) => OrganizationEnvironment.matches(relay, [
152+
relayHost,
153+
otherRelayHost,
154+
]),
155+
enabled: true,
156+
);
159157

160158
setUp(() {
161159
requests = [];
@@ -249,14 +247,9 @@ void main() {
249247
nsec: keys.nsec,
250248
);
251249
final organizationAccount = organizationClient();
252-
final backup = _RecordingKeyBackup(organizationAccount);
253-
final auth = relayAuth(organizationAccount, backup: backup);
250+
final auth = relayAuth(organizationAccount);
254251
await auth.headers(relay);
255252
boundIdentity = {'pubkey_hex': keys.public};
256-
// A background task such as a push revocation for a removed community
257-
// never backs up the key the user is discarding.
258-
await auth.headers(other, background: true);
259-
expect(backup.backedUp, [keys.public]);
260253
// A background task such as a push revocation issues for an inactive
261254
// community while `relay` stays the active session.
262255
await auth.headers(other);
@@ -302,8 +295,7 @@ void main() {
302295
var issued = 0;
303296
tokenFor = (_) => 'token-${++issued}';
304297
final organizationAccount = organizationClient();
305-
final backup = _RecordingKeyBackup(organizationAccount);
306-
final auth = relayAuth(organizationAccount, backup: backup);
298+
final auth = relayAuth(organizationAccount);
307299
int assertions() =>
308300
requests.where((r) => r.url.path.endsWith('/assertions')).length;
309301

@@ -324,13 +316,11 @@ void main() {
324316
'Nostr-Federated-Identity': 'Bearer token-2',
325317
});
326318
expect(auth.cachedHeaders(relay), isNull);
327-
expect(backup.backedUp, isEmpty);
328319

329-
// Foreground use issues its own assertion and backs the key up.
320+
// Foreground use issues its own assertion.
330321
expect(await auth.headers(relay), {
331322
'Nostr-Federated-Identity': 'Bearer token-3',
332323
});
333-
expect(backup.backedUp, [keys.public]);
334324
// Nor does cleanup reuse the session's cached assertion, which the
335325
// relay may already refuse.
336326
expect(await auth.headers(relay, background: true), {
@@ -701,14 +691,3 @@ class _PausedReadStorage extends FlutterSecureStorage {
701691
return super.read(key: key);
702692
}
703693
}
704-
705-
class _RecordingKeyBackup extends OrganizationKeyBackup {
706-
_RecordingKeyBackup(super.account);
707-
708-
final backedUp = <String>[];
709-
710-
@override
711-
Future<void> afterAssertion(String nsec, String pubkey) async {
712-
backedUp.add(pubkey);
713-
}
714-
}

0 commit comments

Comments
 (0)