chore(core): Remove useDirectTLS
This commit is contained in:
parent
f6abf3d5b5
commit
dc24b3c48a
@ -28,7 +28,6 @@ void main() {
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('component.localhost'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
host: '127.0.0.1',
|
||||
port: 8888,
|
||||
);
|
||||
|
@ -29,7 +29,6 @@ void main() {
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('testuser@localhost'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: false,
|
||||
host: '127.0.0.1',
|
||||
port: 5222,
|
||||
);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -34,7 +34,6 @@ void main() {
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('component.example.org'),
|
||||
password: 'abc123',
|
||||
useDirectTLS: true,
|
||||
);
|
||||
await conn.registerManagers([
|
||||
RosterManager(TestingRosterStateManager('', [])),
|
||||
|
@ -26,7 +26,6 @@ class TestingManagerHolder {
|
||||
static final ConnectionSettings settings = ConnectionSettings(
|
||||
jid: jid,
|
||||
password: 'abc123',
|
||||
useDirectTLS: true,
|
||||
);
|
||||
|
||||
Future<XMLNode> _sendStanza(
|
||||
|
@ -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())
|
||||
|
@ -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,
|
||||
|
@ -75,7 +75,6 @@ void main() {
|
||||
)..connectionSettings = ConnectionSettings(
|
||||
jid: JID.fromString('polynomdivision@test.server'),
|
||||
password: 'aaaa',
|
||||
useDirectTLS: true,
|
||||
);
|
||||
await conn.registerManagers([
|
||||
PresenceManager(),
|
||||
|
@ -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<StreamManagementManager>(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
|
||||
// <a h='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(
|
||||
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
||||
'''
|
||||
<stream:stream
|
||||
xmlns="jabber:client"
|
||||
version="1.0"
|
||||
xmlns:stream="http://etherx.jabber.org/streams"
|
||||
from="test.server"
|
||||
xml:lang="en">
|
||||
<stream:features xmlns="http://etherx.jabber.org/streams">
|
||||
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
|
||||
<mechanism>PLAIN</mechanism>
|
||||
</mechanisms>
|
||||
</stream:features>''',
|
||||
),
|
||||
StringExpectation(
|
||||
"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AHBvbHlub21kaXZpc2lvbgBhYWFh</auth>",
|
||||
'<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />',
|
||||
),
|
||||
StringExpectation(
|
||||
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
||||
'''
|
||||
<stream:stream
|
||||
xmlns="jabber:client"
|
||||
version="1.0"
|
||||
xmlns:stream="http://etherx.jabber.org/streams"
|
||||
from="test.server"
|
||||
xml:lang="en">
|
||||
<stream:features xmlns="http://etherx.jabber.org/streams">
|
||||
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
|
||||
<required/>
|
||||
</bind>
|
||||
<session xmlns="urn:ietf:params:xml:ns:xmpp-session">
|
||||
<optional/>
|
||||
</session>
|
||||
<csi xmlns="urn:xmpp:csi:0"/>
|
||||
<sm xmlns="urn:xmpp:sm:3"/>
|
||||
</stream:features>
|
||||
''',
|
||||
),
|
||||
StanzaExpectation(
|
||||
'<iq xmlns="jabber:client" type="set" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>',
|
||||
'<iq xmlns="jabber:client" type="result" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>polynomdivision@test.server/MU29eEZn</jid></bind></iq>',
|
||||
ignoreId: true,
|
||||
),
|
||||
StringExpectation(
|
||||
"<enable xmlns='urn:xmpp:sm:3' resume='true' />",
|
||||
'<enabled xmlns="urn:xmpp:sm:3" id="some-long-sm-id" resume="true" />',
|
||||
)
|
||||
]);
|
||||
|
||||
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([
|
||||
|
@ -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([
|
||||
|
@ -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);
|
||||
|
@ -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('', [])),
|
||||
|
@ -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(),
|
||||
|
@ -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('', [])),
|
||||
|
@ -31,7 +31,6 @@ Future<bool> 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('', [])),
|
||||
|
Loading…
Reference in New Issue
Block a user