Skip to content

Commit

Permalink
Removing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vukoye committed Jan 11, 2021
1 parent f192dff commit 8bc7d56
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions test/connection_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@ import 'package:mockito/mockito.dart';
class MockSocket extends Mock implements Socket {}

void main() {
group('connection tests plain authentication', () {
final firstResponse =
"""<?xml version='1.0'?><stream:stream id='5440668505555980289' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' to='[email protected],' from='test.com' xmlns='jabber:client'><stream:features></stream:features></stream>""";
final authResponse =
'''<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AHRlc3QAdGVzdA==</auth>''';
final authenticating =
"""<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>""";
final authenticationSuccessful =
"""<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>""";
var firstCompleter = Completer();
var secondCompleter = Completer();
var fakeSocketStream =
StreamController<String>.broadcast();
test('test feature negotiation', () async {
final mockSocket = MockSocket();
final connection =
Connection(XmppAccountSettings.fromJid('[email protected]', 'test'));
connection.connectionStateStream.listen((state) {
if (state == XmppConnectionState.DoneParsingFeatures) {
if (!firstCompleter.isCompleted) firstCompleter.complete();
} else if (state == XmppConnectionState.Authenticated) {
secondCompleter.complete();
}
});
connection.socket = mockSocket;
when(mockSocket.write(authResponse)).thenAnswer((_) {
fakeSocketStream.add(authenticationSuccessful);
});
fakeSocketStream.stream.listen(connection.handleResponse);
fakeSocketStream.add(firstResponse);
await firstCompleter.future;
fakeSocketStream.add(authenticating);
await secondCompleter.future;
});
});
// group('connection tests plain authentication', () {
// final firstResponse =
// """<?xml version='1.0'?><stream:stream id='5440668505555980289' version='1.0' xml:lang='en' xmlns:stream='http://etherx.jabber.org/streams' to='[email protected],' from='test.com' xmlns='jabber:client'><stream:features></stream:features></stream>""";
// final authResponse =
// '''<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AHRlc3QAdGVzdA==</auth>''';
// final authenticating =
// """<stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>PLAIN</mechanism><mechanism>SCRAM-SHA-1</mechanism><mechanism>X-OAUTH2</mechanism></mechanisms><register xmlns='http://jabber.org/features/iq-register'/></stream:features>""";
// final authenticationSuccessful =
// """<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>""";
// var firstCompleter = Completer();
// var secondCompleter = Completer();
// var fakeSocketStream =
// StreamController<String>.broadcast();
// test('test feature negotiation', () async {
// final mockSocket = MockSocket();
// final connection =
// Connection(XmppAccountSettings.fromJid('[email protected]', 'test'));
// connection.connectionStateStream.listen((state) {
// if (state == XmppConnectionState.DoneParsingFeatures) {
// if (!firstCompleter.isCompleted) firstCompleter.complete();
// } else if (state == XmppConnectionState.Authenticated) {
// secondCompleter.complete();
// }
// });
// connection.socket = mockSocket;
// when(mockSocket.write(authResponse)).thenAnswer((_) {
// fakeSocketStream.add(authenticationSuccessful);
// });
// fakeSocketStream.stream.listen(connection.handleResponse);
// fakeSocketStream.add(firstResponse);
// await firstCompleter.future;
// fakeSocketStream.add(authenticating);
// await secondCompleter.future;
// });
// });
}

0 comments on commit 8bc7d56

Please sign in to comment.