feat(app): the native app signs in at the web login and carries the session on its socket and downloads
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/session/server_session.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
test('the web login sits beside the websocket endpoint', () {
|
||||
expect(
|
||||
loginUriFor(Uri.parse('wss://host.ts.net:8443/connect')).toString(),
|
||||
'https://host.ts.net:8443/login',
|
||||
);
|
||||
expect(
|
||||
loginUriFor(Uri.parse('ws://192.168.1.2:8081/connect')).toString(),
|
||||
'http://192.168.1.2:8081/login',
|
||||
);
|
||||
expect(loginUriFor(Uri.parse('file:///x')), isNull);
|
||||
});
|
||||
|
||||
test(
|
||||
'a kept session is sent as a cookie header and survives a restart',
|
||||
() async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'pipelines.session.cookie': 'pipelines_session=abc',
|
||||
});
|
||||
await ServerSession.load();
|
||||
expect(ServerSession.headers, {'Cookie': 'pipelines_session=abc'});
|
||||
await ServerSession.signOut();
|
||||
expect(ServerSession.headers, isEmpty);
|
||||
await ServerSession.load();
|
||||
expect(ServerSession.cookie, isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user