diff --git a/integration_tests/test/component_test.dart b/integration_tests/test/component_test.dart index af1a5da..e5b6bc5 100644 --- a/integration_tests/test/component_test.dart +++ b/integration_tests/test/component_test.dart @@ -28,7 +28,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('component.localhost'), password: 'abc123', - useDirectTLS: false, host: '127.0.0.1', port: 8888, ); diff --git a/integration_tests/test/sasl2_test.dart b/integration_tests/test/sasl2_test.dart index 9248e9c..8168dbc 100644 --- a/integration_tests/test/sasl2_test.dart +++ b/integration_tests/test/sasl2_test.dart @@ -29,7 +29,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('testuser@localhost'), password: 'abc123', - useDirectTLS: false, host: '127.0.0.1', port: 5222, ); diff --git a/packages/moxxmpp/CHANGELOG.md b/packages/moxxmpp/CHANGELOG.md index f448255..c665e20 100644 --- a/packages/moxxmpp/CHANGELOG.md +++ b/packages/moxxmpp/CHANGELOG.md @@ -7,6 +7,8 @@ - **BREAKING**: Removed `isFeatureSupported` from the manager attributes. The managers now all have a method `isFeatureSupported` that works the same - The `PresenceManager` is now optional - **BREAKING**: Removed `setConnectionSettings` and `getConnectionSettings`. Just directly acces the `connectionSettings` field. +- Implement XEP-0144 for implementing components +- **BREAKING**: Remove `useDirectTLS` from `ConnectionSettings` ## 0.1.6+1 diff --git a/packages/moxxmpp/lib/src/settings.dart b/packages/moxxmpp/lib/src/settings.dart index a8f34e9..22bd7f3 100644 --- a/packages/moxxmpp/lib/src/settings.dart +++ b/packages/moxxmpp/lib/src/settings.dart @@ -4,7 +4,6 @@ class ConnectionSettings { ConnectionSettings({ required this.jid, required this.password, - required this.useDirectTLS, this.host, this.port, }); @@ -15,9 +14,6 @@ class ConnectionSettings { /// The password to use during authentication. final String password; - /// Directly use TLS while connecting. Only effective if [host] and [port] are null. - final bool useDirectTLS; - /// The host to connect to. Skips DNS resolution if specified. final String? host; diff --git a/packages/moxxmpp/test/component_test.dart b/packages/moxxmpp/test/component_test.dart index f17d89b..f40ba42 100644 --- a/packages/moxxmpp/test/component_test.dart +++ b/packages/moxxmpp/test/component_test.dart @@ -34,7 +34,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('component.example.org'), password: 'abc123', - useDirectTLS: true, ); await conn.registerManagers([ RosterManager(TestingRosterStateManager('', [])), diff --git a/packages/moxxmpp/test/helpers/manager.dart b/packages/moxxmpp/test/helpers/manager.dart index 8a14855..959d70a 100644 --- a/packages/moxxmpp/test/helpers/manager.dart +++ b/packages/moxxmpp/test/helpers/manager.dart @@ -26,7 +26,6 @@ class TestingManagerHolder { static final ConnectionSettings settings = ConnectionSettings( jid: jid, password: 'abc123', - useDirectTLS: true, ); Future _sendStanza( diff --git a/packages/moxxmpp/test/negotiator_test.dart b/packages/moxxmpp/test/negotiator_test.dart index 12a2160..bd112c4 100644 --- a/packages/moxxmpp/test/negotiator_test.dart +++ b/packages/moxxmpp/test/negotiator_test.dart @@ -58,7 +58,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('test'), password: 'abc123', - useDirectTLS: false, ), ) ..registerNegotiator(StubNegotiator1()) @@ -77,7 +76,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('test'), password: 'abc123', - useDirectTLS: false, ), ) ..registerNegotiator(StubNegotiator1()) diff --git a/packages/moxxmpp/test/sasl/scram_test.dart b/packages/moxxmpp/test/sasl/scram_test.dart index 040be15..3e64e3c 100644 --- a/packages/moxxmpp/test/sasl/scram_test.dart +++ b/packages/moxxmpp/test/sasl/scram_test.dart @@ -55,7 +55,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ), (_) async {}, getNegotiatorNullStub, @@ -157,7 +156,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ), (_) async {}, getNegotiatorNullStub, @@ -214,7 +212,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ), (_) async {}, getNegotiatorNullStub, @@ -261,7 +258,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ), (_) async {}, getNegotiatorNullStub, @@ -311,7 +307,6 @@ void main() { () => ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ), (_) async {}, getNegotiatorNullStub, diff --git a/packages/moxxmpp/test/xeps/xep_0030_test.dart b/packages/moxxmpp/test/xeps/xep_0030_test.dart index 21c80e5..85e703c 100644 --- a/packages/moxxmpp/test/xeps/xep_0030_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0030_test.dart @@ -75,7 +75,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), diff --git a/packages/moxxmpp/test/xeps/xep_0198_test.dart b/packages/moxxmpp/test/xeps/xep_0198_test.dart index cbd4f9b..fead91d 100644 --- a/packages/moxxmpp/test/xeps/xep_0198_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0198_test.dart @@ -61,7 +61,6 @@ XmppManagerAttributes mkAttributes(void Function(Stanza) callback) { getConnectionSettings: () => ConnectionSettings( jid: JID.fromString('hallo@example.server'), password: 'password', - useDirectTLS: true, ), getFullJID: () => JID.fromString('hallo@example.server/uwu'), getSocket: () => StubTCPSocket([]), @@ -286,7 +285,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); final sm = StreamManagementManager(); await conn.registerManagers([ @@ -410,166 +408,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, - ); - final sm = StreamManagementManager(); - await conn.registerManagers([ - PresenceManager(), - RosterManager(TestingRosterStateManager('', [])), - DiscoManager([]), - sm, - CarbonsManager()..forceEnable(), - //EntityCapabilitiesManager('http://moxxmpp.example'), - ]); - await conn.registerFeatureNegotiators([ - SaslPlainNegotiator(), - ResourceBindingNegotiator(), - StreamManagementNegotiator(), - ]); - - await conn.connect( - waitUntilLogin: true, - ); - expect(fakeSocket.getState(), 6); - expect(await conn.getConnectionState(), XmppConnectionState.connected); - expect( - conn - .getManagerById(smManager)! - .isStreamManagementEnabled(), - true, - ); - - // Await an iq - await conn.sendStanza( - Stanza.iq( - to: 'user@example.com', - type: 'get', - ), - addFrom: StanzaFromType.none, - ); - - expect(sm.state.s2c, 2); - }); - }); - - group('Stream resumption', () { - test('Stanza retransmission', () async { - var stanzaCount = 0; - final attributes = mkAttributes((_) { - stanzaCount++; - }); - final manager = StreamManagementManager()..register(attributes); - - await manager.onXmppEvent( - StreamManagementEnabledEvent(resource: 'hallo'), - ); - - // Send 5 stanzas - for (var i = 0; i < 5; i++) { - await runOutgoingStanzaHandlers(manager, stanza); - } - - // Only ack 3 - // - await manager.runNonzaHandlers(mkAck(3)); - expect(manager.getUnackedStanzas().length, 2); - - // Lose connection - // [ Reconnect ] - await manager.onXmppEvent(StreamResumedEvent(h: 3)); - - expect(stanzaCount, 2); - }); - test('Resumption with prior state', () async { - var stanzaCount = 0; - final attributes = mkAttributes((_) { - stanzaCount++; - }); - final manager = StreamManagementManager()..register(attributes); - - // [ ... ] - await manager.onXmppEvent( - StreamManagementEnabledEvent(resource: 'hallo'), - ); - await manager.setState(manager.state.copyWith(c2s: 150, s2c: 70)); - - // Send some stanzas but don't ack them - for (var i = 0; i < 5; i++) { - await runOutgoingStanzaHandlers(manager, stanza); - } - expect(manager.getUnackedStanzas().length, 5); - - // Lose connection - // [ Reconnect ] - await manager.onXmppEvent(StreamResumedEvent(h: 150)); - expect(manager.getUnackedStanzas().length, 0); - expect(stanzaCount, 5); - }); - }); - - group('Test the negotiator', () { - test('Test successful stream enablement', () async { - final fakeSocket = StubTCPSocket([ - StringExpectation( - "", - ''' - - - - PLAIN - - ''', - ), - StringExpectation( - "AHBvbHlub21kaXZpc2lvbgBhYWFh", - '', - ), - StringExpectation( - "", - ''' - - - - - - - - - - - -''', - ), - StanzaExpectation( - '', - 'polynomdivision@test.server/MU29eEZn', - ignoreId: true, - ), - StringExpectation( - "", - '', - ) - ]); - - final conn = XmppConnection( - TestingReconnectionPolicy(), - AlwaysConnectedConnectivityManager(), - ClientToServerNegotiator(), - fakeSocket, - )..connectionSettings = ConnectionSettings( - jid: JID.fromString('polynomdivision@test.server'), - password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -662,7 +500,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -752,7 +589,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -839,7 +675,6 @@ void main() { ..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ) ..setResource('test-resource', triggerEvent: false); await conn.registerManagers([ @@ -937,7 +772,6 @@ void main() { ..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ) ..setResource('test-resource', triggerEvent: false); await conn.registerManagers([ @@ -1039,7 +873,6 @@ void main() { ..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ) ..setResource('test-resource', triggerEvent: false); await conn.registerManagers([ diff --git a/packages/moxxmpp/test/xeps/xep_0280_test.dart b/packages/moxxmpp/test/xeps/xep_0280_test.dart index 11d8bf9..464c1f9 100644 --- a/packages/moxxmpp/test/xeps/xep_0280_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0280_test.dart @@ -28,7 +28,6 @@ void main() { getConnectionSettings: () => ConnectionSettings( jid: JID.fromString('bob@xmpp.example'), password: 'password', - useDirectTLS: true, ), getFullJID: () => JID.fromString('bob@xmpp.example/uwu'), getSocket: () => StubTCPSocket([]), @@ -110,7 +109,6 @@ void main() { ..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ) ..setResource('test-resource', triggerEvent: false); await conn.registerManagers([ diff --git a/packages/moxxmpp/test/xeps/xep_0352_test.dart b/packages/moxxmpp/test/xeps/xep_0352_test.dart index fd70995..fb252b4 100644 --- a/packages/moxxmpp/test/xeps/xep_0352_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0352_test.dart @@ -54,7 +54,6 @@ void main() { getConnectionSettings: () => ConnectionSettings( jid: JID.fromString('some.user@example.server'), password: 'password', - useDirectTLS: true, ), getManagerById: getManagerNullStub, getNegotiatorById: getUnsupportedCSINegotiator, @@ -98,7 +97,6 @@ void main() { getConnectionSettings: () => ConnectionSettings( jid: JID.fromString('some.user@example.server'), password: 'password', - useDirectTLS: true, ), getManagerById: getManagerNullStub, getNegotiatorById: getSupportedCSINegotiator, @@ -174,7 +172,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); final csi = CSIManager(); await csi.setInactive(sendNonza: false); diff --git a/packages/moxxmpp/test/xeps/xep_0386_test.dart b/packages/moxxmpp/test/xeps/xep_0386_test.dart index 39915c9..fbe5401 100644 --- a/packages/moxxmpp/test/xeps/xep_0386_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0386_test.dart @@ -49,7 +49,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -121,7 +120,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ RosterManager(TestingRosterStateManager('', [])), diff --git a/packages/moxxmpp/test/xeps/xep_0388_test.dart b/packages/moxxmpp/test/xeps/xep_0388_test.dart index 8918d10..83e07ac 100644 --- a/packages/moxxmpp/test/xeps/xep_0388_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0388_test.dart @@ -106,7 +106,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -185,7 +184,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -263,7 +261,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('user@server'), password: 'pencil', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -349,7 +346,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -433,7 +429,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), diff --git a/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart b/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart index b6b1722..c7feaef 100644 --- a/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart +++ b/packages/moxxmpp/test/xeps/xep_xxxx_fast_test.dart @@ -112,7 +112,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ RosterManager(TestingRosterStateManager('', [])), @@ -226,7 +225,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ RosterManager(TestingRosterStateManager('', [])), diff --git a/packages/moxxmpp/test/xmpp_test.dart b/packages/moxxmpp/test/xmpp_test.dart index 2242f0b..abb1ad4 100644 --- a/packages/moxxmpp/test/xmpp_test.dart +++ b/packages/moxxmpp/test/xmpp_test.dart @@ -31,7 +31,6 @@ Future testRosterManager( getConnectionSettings: () => ConnectionSettings( jid: JID.fromString(bareJid), password: 'password', - useDirectTLS: true, ), getManagerById: getManagerNullStub, getNegotiatorById: getNegotiatorNullStub, @@ -130,7 +129,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -186,7 +184,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -244,7 +241,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('polynomdivision@test.server'), password: 'aaaa', - useDirectTLS: true, ); await conn.registerManagers([ PresenceManager(), @@ -290,7 +286,6 @@ void main() { getConnectionSettings: () => ConnectionSettings( jid: JID.fromString('some.user@example.server'), password: 'password', - useDirectTLS: true, ), getManagerById: getManagerNullStub, getNegotiatorById: getNegotiatorNullStub, @@ -403,7 +398,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('testuser@example.org'), password: 'abc123', - useDirectTLS: false, ); await conn.registerManagers([ PresenceManager(), @@ -497,7 +491,6 @@ void main() { )..connectionSettings = ConnectionSettings( jid: JID.fromString('testuser@example.org'), password: 'abc123', - useDirectTLS: false, ); await conn.registerManagers([ RosterManager(TestingRosterStateManager('', [])),