Skip to content

Commit

Permalink
fix: client tests had to be updated with new client domain
Browse files Browse the repository at this point in the history
  • Loading branch information
CMCDragonkai committed Oct 12, 2023
1 parent 4c0c9f2 commit 9838c1c
Show file tree
Hide file tree
Showing 13 changed files with 1,605 additions and 3,105 deletions.
2 changes: 1 addition & 1 deletion src/client/callers/notificationsSend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { HandlerTypes } from '@matrixai/rpc';
import type NotificationsSend from '../handlers/NotificationsRead';
import type NotificationsSend from '../handlers/NotificationsSend';
import { UnaryCaller } from '@matrixai/rpc';

type CallerTypes = HandlerTypes<NotificationsSend>;
Expand Down
3 changes: 1 addition & 2 deletions src/client/handlers/KeysPublicKey.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {
ClientRPCRequestParams,
ClientRPCResponseResult,
PasswordMessage,
PublicKeyMessage,
} from '../types';
import type KeyRing from '../../keys/KeyRing';
Expand All @@ -12,7 +11,7 @@ class KeysPublicKey extends UnaryHandler<
{
keyRing: KeyRing;
},
ClientRPCRequestParams<PasswordMessage>,
ClientRPCRequestParams,
ClientRPCResponseResult<PublicKeyMessage>
> {
public handle = async (): Promise<
Expand Down
2 changes: 1 addition & 1 deletion src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type KeyRing from '../keys/KeyRing';
import type { Certificate, CertificatePEM } from '../keys/types';
import type { NodeId } from '../ids';
import { utils as wsUtils } from '@matrixai/ws';
import * as keysUtils from '../keys/utils';
import * as clientErrors from './errors';
import * as keysUtils from '../keys/utils';

async function authenticate(
sessionManager: SessionManager,
Expand Down
23 changes: 8 additions & 15 deletions tests/client/ClientService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TLSConfig } from '@/network/types';
import Logger, { formatting, LogLevel, StreamHandler } from '@matrixai/logger';
import ClientService from '@/client/ClientService';
import * as keysUtils from '@/keys/utils';
import * as utils from '../utils';
import * as testsUtils from '../utils';

describe(`ClientService tests`, () => {
const logger = new Logger(`${ClientService.name} test`, LogLevel.WARN, [
Expand All @@ -11,32 +11,25 @@ describe(`ClientService tests`, () => {
),
]);
const localHost = '127.0.0.1';

let clientService: ClientService;
let tlsConfig: TLSConfig;

beforeEach(async () => {
tlsConfig = await utils.createTLSConfig(keysUtils.generateKeyPair());
tlsConfig = await testsUtils.createTLSConfig(keysUtils.generateKeyPair());
});
afterEach(async () => {
await clientService?.stop({ force: true });
});

test('ClientService readiness', async () => {
clientService = await ClientService.createClientService({
manifest: {},
options: {
host: localHost,
},
clientService = new ClientService({
tlsConfig,
logger,
logger: logger.getChild(ClientService.name),
});
await clientService.start({
manifest: {},
host: localHost,
});
await clientService.stop({ force: true });
// Should be a noop
await clientService.stop({ force: true });
await clientService.destroy();
// Should be a noop
await clientService.destroy();
});
// TODO: tests?
});
24 changes: 12 additions & 12 deletions tests/client/authenticationMiddleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import {
} from '@matrixai/rpc';
import { WebSocketClient } from '@matrixai/ws';
import KeyRing from '@/keys/KeyRing';
import * as keysUtils from '@/keys/utils';
import TaskManager from '@/tasks/TaskManager';
import CertManager from '@/keys/CertManager';
import ClientService from '@/client/ClientService';
import { Session, SessionManager } from '@/sessions';
import * as authMiddleware from '@/client/authenticationMiddleware';
import * as keysUtils from '@/keys/utils';
import * as clientUtils from '@/client/utils';
import * as authMiddleware from '@/client/utils/authenticationMiddleware';
import ClientService from '@/client/ClientService';
import * as networkUtils from '@/network/utils';
import * as testsUtils from '../utils';

Expand Down Expand Up @@ -107,19 +107,19 @@ describe('authenticationMiddleware', () => {
return input;
}
}
clientService = await ClientService.createClientService({
clientService = new ClientService({
tlsConfig,
middlewareFactory: authMiddleware.authenticationMiddlewareServer(
sessionManager,
keyRing,
),
logger: logger.getChild(ClientService.name),
});
await clientService.start({
manifest: {
testHandler: new EchoHandler({ logger }),
},
options: {
host: localhost,
middlewareFactory: authMiddleware.authenticationMiddlewareServer(
sessionManager,
keyRing,
),
},
logger: logger.getChild(ClientService.name),
host: localhost,
});
clientClient = await WebSocketClient.createWebSocketClient({
config: {
Expand Down
Loading

0 comments on commit 9838c1c

Please sign in to comment.