tests: Fix tests

This commit is contained in:
PapaTutuWawa 2023-01-07 18:40:36 +01:00
parent 67446285c1
commit 473f8e4bb6
4 changed files with 22 additions and 15 deletions

View File

@ -1,5 +1,6 @@
import 'dart:async';
import 'package:moxxmpp/src/jid.dart';
import 'package:moxxmpp/src/managers/attributes.dart';
import 'package:moxxmpp/src/managers/base.dart';
import 'package:moxxmpp/src/managers/data.dart';
import 'package:moxxmpp/src/managers/handlers.dart';
@ -66,10 +67,16 @@ class RosterFeatureNegotiator extends XmppFeatureNegotiatorBase {
/// This manager requires a RosterFeatureNegotiator to be registered.
class RosterManager extends XmppManagerBase {
RosterManager(this._stateManager) : super() {
_stateManager.register(getAttributes().sendEvent);
}
RosterManager(this._stateManager) : super();
/// The class managing the entire roster state.
final BaseRosterStateManager _stateManager;
@override
void register(XmppManagerAttributes attributes) {
super.register(attributes);
_stateManager.register(attributes.sendEvent);
}
@override
String getId() => rosterManager;

View File

@ -61,7 +61,7 @@ void main() {
])
..registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
])

View File

@ -243,7 +243,7 @@ void main() {
final sm = StreamManagementManager();
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
sm,
@ -365,7 +365,7 @@ void main() {
final sm = StreamManagementManager();
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
sm,
@ -519,7 +519,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
StreamManagementManager(),
@ -611,7 +611,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
StreamManagementManager(),
@ -703,7 +703,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
StreamManagementManager(),

View File

@ -7,7 +7,7 @@ import 'helpers/xmpp.dart';
/// Returns true if the roster manager triggeres an event for a given stanza
Future<bool> testRosterManager(String bareJid, String resource, String stanzaString) async {
var eventTriggered = false;
final roster = RosterManager();
final roster = RosterManager(TestingRosterStateManager('', []));
roster.register(XmppManagerAttributes(
sendStanza: (_, { StanzaFromType addFrom = StanzaFromType.full, bool addId = true, bool retransmitted = false, bool awaitable = true, bool encrypted = false }) async => XMLNode(tag: 'hallo'),
sendEvent: (event) {
@ -127,7 +127,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
StreamManagementManager(),
@ -181,7 +181,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
]);
@ -235,7 +235,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
]);
@ -290,7 +290,7 @@ void main() {
),);
conn.registerManagers([
PresenceManager('http://moxxmpp.example'),
RosterManager(),
RosterManager(TestingRosterStateManager('', [])),
DiscoManager(),
PingManager(),
]);
@ -308,7 +308,7 @@ void main() {
group('Test roster pushes', () {
test('Test for a CVE-2015-8688 style vulnerability', () async {
var eventTriggered = false;
final roster = RosterManager();
final roster = RosterManager(TestingRosterStateManager('', []));
roster.register(XmppManagerAttributes(
sendStanza: (_, { StanzaFromType addFrom = StanzaFromType.full, bool addId = true, bool retransmitted = false, bool awaitable = true, bool encrypted = false }) async => XMLNode(tag: 'hallo'),
sendEvent: (event) {