fix: actually make sure clientBox has a account
This commit is contained in:
parent
4a8f628706
commit
65c0f8119c
|
|
@ -133,7 +133,8 @@ class FakeMatrixApi extends BaseClient {
|
||||||
}
|
}
|
||||||
if (!servers.contains(request.url.origin)) {
|
if (!servers.contains(request.url.origin)) {
|
||||||
return Response(
|
return Response(
|
||||||
'<html><head></head><body>Not found...</body></html>', 404);
|
'<html><head></head><body>Not found ${request.url.origin}...</body></html>',
|
||||||
|
404);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!{
|
if (!{
|
||||||
|
|
@ -1158,7 +1159,7 @@ class FakeMatrixApi extends BaseClient {
|
||||||
'/media/v3/config': (var req) => {'m.upload.size': 50000000},
|
'/media/v3/config': (var req) => {'m.upload.size': 50000000},
|
||||||
'/client/v1/media/config': (var req) => {'m.upload.size': 50000000},
|
'/client/v1/media/config': (var req) => {'m.upload.size': 50000000},
|
||||||
'/.well-known/matrix/client': (var req) => {
|
'/.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'},
|
'm.identity_server': {'base_url': 'https://identity.example.com'},
|
||||||
'org.example.custom.property': {
|
'org.example.custom.property': {
|
||||||
'app_url': 'https://custom.app.example.org'
|
'app_url': 'https://custom.app.example.org'
|
||||||
|
|
|
||||||
|
|
@ -1880,7 +1880,12 @@ class Client extends MatrixApi {
|
||||||
|
|
||||||
final account = await this.database?.getClient(clientName);
|
final account = await this.database?.getClient(clientName);
|
||||||
newRefreshToken ??= account?.tryGet<String>('refresh_token');
|
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'];
|
_id = account['client_id'];
|
||||||
homeserver = Uri.parse(account['homeserver_url']);
|
homeserver = Uri.parse(account['homeserver_url']);
|
||||||
accessToken = this.accessToken = account['token'];
|
accessToken = this.accessToken = account['token'];
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,28 @@ void main() {
|
||||||
matrix = await getClient();
|
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 {
|
test('Login', () async {
|
||||||
matrix = Client(
|
matrix = Client(
|
||||||
'testclient',
|
'testclient',
|
||||||
|
|
@ -1173,7 +1195,8 @@ void main() {
|
||||||
final client = await getClient();
|
final client = await getClient();
|
||||||
expect(client.wellKnown, null);
|
expect(client.wellKnown, null);
|
||||||
await client.getWellknown();
|
await client.getWellknown();
|
||||||
expect(client.wellKnown?.mHomeserver.baseUrl.host, 'matrix.example.com');
|
expect(
|
||||||
|
client.wellKnown?.mHomeserver.baseUrl.host, 'fakeserver.notexisting');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('refreshAccessToken', () async {
|
test('refreshAccessToken', () async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue