94 lines
2.3 KiB
Dart
94 lines
2.3 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:hepan_everyday/features/school/school_login_flow.dart';
|
|
|
|
void main() {
|
|
test('wait for student authentication then request timetable once', () {
|
|
final flow = SchoolLoginFlow();
|
|
final target = Uri.parse(
|
|
'https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1',
|
|
);
|
|
flow.begin(target);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse(
|
|
'https://idas.uestc.edu.cn/authserver/login?service=graduate',
|
|
),
|
|
authenticated: false,
|
|
),
|
|
isNull,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('http://yjsjy.uestc.edu.cn/pyxx/jzsso/login?ticket=ST-test'),
|
|
authenticated: false,
|
|
),
|
|
isNull,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('http://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
target,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
isNull,
|
|
);
|
|
expect(flow.onLoaded(target, authenticated: true), isNull);
|
|
flow.reset();
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
isNull,
|
|
);
|
|
});
|
|
test(
|
|
'reauthentication and untrusted redirects cannot jump into timetable',
|
|
() {
|
|
final flow = SchoolLoginFlow();
|
|
final target = Uri.parse(
|
|
'https://yjsjy.uestc.edu.cn/pyxx/pygl/xskbcx/index/1',
|
|
);
|
|
flow.begin(target);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://evil.test/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
isNull,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: false,
|
|
),
|
|
isNull,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
target,
|
|
);
|
|
flow.onLoaded(
|
|
Uri.parse('https://idas.uestc.edu.cn/authserver/login'),
|
|
authenticated: false,
|
|
);
|
|
expect(
|
|
flow.onLoaded(
|
|
Uri.parse('https://yjsjy.uestc.edu.cn/pyxx/home/index'),
|
|
authenticated: true,
|
|
),
|
|
target,
|
|
);
|
|
},
|
|
);
|
|
}
|