feat(xep): FASTSaslNegotiator now only takes a string as its token

This commit is contained in:
PapaTutuWawa 2023-06-11 22:22:45 +02:00
parent aa71d3ed5d
commit fa2ce7c2d1
2 changed files with 10 additions and 15 deletions

View File

@ -60,7 +60,7 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator {
final Logger _log = Logger('FASTSaslNegotiator'); final Logger _log = Logger('FASTSaslNegotiator');
/// The token, if non-null, to use for authentication. /// The token, if non-null, to use for authentication.
FASTToken? fastToken; String? fastToken;
@override @override
bool matchesFeature(List<XMLNode> features) { bool matchesFeature(List<XMLNode> features) {
@ -100,11 +100,12 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator {
@override @override
Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async { Future<Result<bool, NegotiatorError>> onSasl2Success(XMLNode response) async {
final token = response.firstTag('token', xmlns: fastXmlns); final tokenElement = response.firstTag('token', xmlns: fastXmlns);
if (token != null) { if (tokenElement != null) {
fastToken = FASTToken.fromXml(token); final token = FASTToken.fromXml(tokenElement);
fastToken = token.token;
await attributes.sendEvent( await attributes.sendEvent(
NewFASTTokenReceivedEvent(fastToken!), NewFASTTokenReceivedEvent(token),
); );
} }
@ -155,7 +156,7 @@ class FASTSaslNegotiator extends Sasl2AuthenticationNegotiator {
@override @override
Future<String> getRawStep(String input) async { Future<String> getRawStep(String input) async {
return fastToken!.token; return fastToken!;
} }
@override @override

View File

@ -141,8 +141,7 @@ void main() {
final token = conn final token = conn
.getNegotiatorById<FASTSaslNegotiator>(saslFASTNegotiator)! .getNegotiatorById<FASTSaslNegotiator>(saslFASTNegotiator)!
.fastToken; .fastToken;
expect(token != null, true); expect(token, 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm');
expect(token!.token, 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm');
// Disconnect // Disconnect
await conn.disconnect(); await conn.disconnect();
@ -232,11 +231,7 @@ void main() {
await conn.registerFeatureNegotiators([ await conn.registerFeatureNegotiators([
SaslPlainNegotiator(), SaslPlainNegotiator(),
ResourceBindingNegotiator(), ResourceBindingNegotiator(),
FASTSaslNegotiator() FASTSaslNegotiator()..fastToken = 'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm',
..fastToken = const FASTToken(
'WXZzciBwYmFmdmZnZiBqdmd1IGp2eXFhcmZm',
'2020-03-12T14:36:15Z',
),
Sasl2Negotiator() Sasl2Negotiator()
..userAgent = const UserAgent( ..userAgent = const UserAgent(
id: 'd4565fa7-4d72-4749-b3d3-740edbf87770', id: 'd4565fa7-4d72-4749-b3d3-740edbf87770',
@ -257,7 +252,6 @@ void main() {
final token = conn final token = conn
.getNegotiatorById<FASTSaslNegotiator>(saslFASTNegotiator)! .getNegotiatorById<FASTSaslNegotiator>(saslFASTNegotiator)!
.fastToken; .fastToken;
expect(token != null, true); expect(token, 'ed00e36cb42449a365a306a413f51ffd5ea8');
expect(token!.token, 'ed00e36cb42449a365a306a413f51ffd5ea8');
}); });
} }