32 lines
1 KiB
Dart
32 lines
1 KiB
Dart
|
|
import 'package:halkyon_base_server/base.dart';
|
||
|
|
import 'package:test/test.dart';
|
||
|
|
|
||
|
|
// SIGN_IN_WAYS (ADR 0020, 1): the ways in an operator offers.
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
test('unset or empty, every way whose keys are there', () {
|
||
|
|
expect(offeredWaysFrom(null), isNull);
|
||
|
|
expect(offeredWaysFrom(''), isNull);
|
||
|
|
expect(offeredWaysFrom(' '), isNull);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('names one way or both, by commas or spaces, whatever their case', () {
|
||
|
|
expect(offeredWaysFrom('simplelogin'), {OfferedWay.simpleLogin});
|
||
|
|
expect(offeredWaysFrom('password'), {OfferedWay.password});
|
||
|
|
expect(offeredWaysFrom('password, SimpleLogin'), {
|
||
|
|
OfferedWay.password,
|
||
|
|
OfferedWay.simpleLogin,
|
||
|
|
});
|
||
|
|
expect(offeredWaysFrom('simplelogin password'), hasLength(2));
|
||
|
|
});
|
||
|
|
|
||
|
|
test('refuses a way it does not know, so the server stops as it starts', () {
|
||
|
|
for (final value in ['github', 'simplelogin,email', 'passwords']) {
|
||
|
|
expect(
|
||
|
|
() => offeredWaysFrom(value),
|
||
|
|
throwsA(isA<StateError>()),
|
||
|
|
reason: value,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|