Merge pull request #1910 from famedly/td/wellKnownBreakFix
fix: actually make sure clientBox has a account
This commit is contained in:
commit
9b8fa95a52
|
|
@ -133,7 +133,8 @@ class FakeMatrixApi extends BaseClient {
|
|||
}
|
||||
if (!servers.contains(request.url.origin)) {
|
||||
return Response(
|
||||
'<html><head></head><body>Not found...</body></html>', 404);
|
||||
'<html><head></head><body>Not found ${request.url.origin}...</body></html>',
|
||||
404);
|
||||
}
|
||||
|
||||
if (!{
|
||||
|
|
@ -1158,7 +1159,7 @@ class FakeMatrixApi extends BaseClient {
|
|||
'/media/v3/config': (var req) => {'m.upload.size': 50000000},
|
||||
'/client/v1/media/config': (var req) => {'m.upload.size': 50000000},
|
||||
'/.well-known/matrix/client': (var req) => {
|
||||
'm.homeserver': {'base_url': 'https://matrix.example.com'},
|
||||
'm.homeserver': {'base_url': 'https://fakeserver.notexisting'},
|
||||
'm.identity_server': {'base_url': 'https://identity.example.com'},
|
||||
'org.example.custom.property': {
|
||||
'app_url': 'https://custom.app.example.org'
|
||||
|
|
|
|||
|
|
@ -1880,7 +1880,12 @@ class Client extends MatrixApi {
|
|||
|
||||
final account = await this.database?.getClient(clientName);
|
||||
newRefreshToken ??= account?.tryGet<String>('refresh_token');
|
||||
if (account != null) {
|
||||
// can have discovery_information so make sure it also has the proper
|
||||
// account creds
|
||||
if (account != null &&
|
||||
account['homeserver_url'] != null &&
|
||||
account['user_id'] != null &&
|
||||
account['token'] != null) {
|
||||
_id = account['client_id'];
|
||||
homeserver = Uri.parse(account['homeserver_url']);
|
||||
accessToken = this.accessToken = account['token'];
|
||||
|
|
|
|||
|
|
@ -70,6 +70,28 @@ void main() {
|
|||
matrix = await getClient();
|
||||
});
|
||||
|
||||
test('barebones client login', () async {
|
||||
final client = Client(
|
||||
'testclient',
|
||||
httpClient: FakeMatrixApi(),
|
||||
databaseBuilder: getDatabase,
|
||||
);
|
||||
expect(client.isLogged(), false);
|
||||
await client.init();
|
||||
expect(client.isLogged(), false);
|
||||
await client.login(
|
||||
LoginType.mLoginPassword,
|
||||
token: 'abcd',
|
||||
identifier:
|
||||
AuthenticationUserIdentifier(user: '@test:fakeServer.notExisting'),
|
||||
deviceId: 'GHTYAJCE',
|
||||
);
|
||||
|
||||
expect(client.isLogged(), true);
|
||||
|
||||
await client.logout();
|
||||
});
|
||||
|
||||
test('Login', () async {
|
||||
matrix = Client(
|
||||
'testclient',
|
||||
|
|
@ -1173,7 +1195,8 @@ void main() {
|
|||
final client = await getClient();
|
||||
expect(client.wellKnown, null);
|
||||
await client.getWellknown();
|
||||
expect(client.wellKnown?.mHomeserver.baseUrl.host, 'matrix.example.com');
|
||||
expect(
|
||||
client.wellKnown?.mHomeserver.baseUrl.host, 'fakeserver.notexisting');
|
||||
});
|
||||
|
||||
test('refreshAccessToken', () async {
|
||||
|
|
|
|||
Loading…
Reference in New Issue