From fa2ce7c2d10042246e19249f672ce32f90bab087 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sun, 11 Jun 2023 22:22:45 +0200 Subject: [PATCH] feat(xep): FASTSaslNegotiator now only takes a string as its token --- packages/moxxmpp/lib/src/xeps/staging/fast.dart | 13 +++++++------ packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart | 12 +++--------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/packages/moxxmpp/lib/src/xeps/staging/fast.dart b/packages/moxxmpp/lib/src/xeps/staging/fast.dart index 83785ad..3a873fd 100644 --- a/packages/moxxmpp/lib/src/xeps/staging/fast.dart +++ b/packages/moxxmpp/lib/src/xeps/staging/fast.dart @@ -60,7 +60,7 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator { final Logger _log = Logger('FASTSaslNegotiator'); /// The token, if non-null, to use for authentication. - FASTToken? fastToken; + String? fastToken; @override bool matchesFeature(List features) { @@ -100,11 +100,12 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator { @override Future> onSasl2Success(XMLNode response) async { - final token = response.firstTag('token', xmlns: fastXmlns); - if (token != null) { - fastToken = FASTToken.fromXml(token); + final tokenElement = response.firstTag('token', xmlns: fastXmlns); + if (tokenElement != null) { + final token = FASTToken.fromXml(tokenElement); + fastToken = token.token; await attributes.sendEvent( - NewFASTTokenReceivedEvent(fastToken!), + NewFASTTokenReceivedEvent(token), ); } @@ -155,7 +156,7 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator { @override Future getRawStep(String input) async { - return fastToken!.token; + return fastToken!; } @override diff --git a/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart b/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart index c3e736a..e68a89b 100644 --- a/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart +++ b/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart @@ -141,8 +141,7 @@ void main() { final token = conn .getNegotiatorById(saslFASTNegotiator)! .fastToken; - expect(token != null, true); - expect(token!.token, 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm'); + expect(token, 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm'); // Disconnect await conn.disconnect(); @@ -232,11 +231,7 @@ void main() { await conn.registerFeatureNegotiators([ SaslPlainNegotiator(), ResourceBindingNegotiator(), - FASTSaslNegotiator() - ..fastToken = const FASTToken( - 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm', - '2020-03-12T14:36:15Z', - ), + FASTSaslNegotiator()..fastToken = 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm', Sasl2Negotiator() ..userAgent = const UserAgent( id: 'd4565fa7-4d72-4749-b3d3-740edbf87770', @@ -257,7 +252,6 @@ void main() { final token = conn .getNegotiatorById(saslFASTNegotiator)! .fastToken; - expect(token != null, true); - expect(token!.token, 'ed00e36cb42449a365a306a413f51ffd5ea8'); + expect(token, 'ed00e36cb42449a365a306a413f51ffd5ea8'); }); }