Skip to content

Commit 144bc64

Browse files
committed
Enhance CreateEndpointResponseData and Endpoint models with token property; update tests to validate new structure and behavior
1 parent b2ae627 commit 144bc64

4 files changed

Lines changed: 26 additions & 19 deletions

File tree

models/create-endpoint-response-data.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import type { EndpointTypeEnum } from './endpoint-type-enum';
2929
/**
3030
* @type CreateEndpointResponseData
3131
*/
32-
export type CreateEndpointResponseData = Endpoint;
33-
34-
32+
export interface CreateEndpointResponseData extends Endpoint {
33+
/**
34+
* The json web token specific to the endpoint. Used to authenticate the client with the media gateway.
35+
*/
36+
'token': string;
37+
}

models/endpoint.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ import type { Endpoints } from './endpoints';
2929
/**
3030
* @type Endpoint
3131
*/
32-
export type Endpoint = Endpoints;
33-
34-
32+
export interface Endpoint extends Endpoints {
33+
'devices'?: Array<Device>;
34+
}

tests/smoke/endpoints-api.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ts-nocheck
22
import { EndpointsApi } from '../../api';
33
import { Configuration } from '../../configuration';
4-
import { CreateWebRtcConnectionRequest, EndpointStatusEnum, EndpointTypeEnum } from '../../models';
4+
import { CreateWebRtcConnectionRequest, EndpointDirectionEnum, EndpointStatusEnum, EndpointTypeEnum } from '../../models';
55

66
describe('EndpointsApi', () => {
77
const config = new Configuration({
@@ -27,16 +27,17 @@ describe('EndpointsApi', () => {
2727
describe('createEndpoint', () => {
2828
test('should create a new endpoint', async () => {
2929
const endpointBody: CreateWebRtcConnectionRequest = {
30-
name: 'Test Endpoint',
31-
displayName: 'Test WebRTC Endpoint'
30+
type: EndpointTypeEnum.Webrtc,
31+
direction: EndpointDirectionEnum.Bidirectional
3232
};
3333

3434
const { status, data } = await endpointsApi.createEndpoint(BW_ACCOUNT_ID, endpointBody);
3535

3636
expect(status).toEqual(201);
3737
expect(data.endpointId).toBeDefined();
38+
expect(data.token).toBeDefined();
3839
expect(data.type).toEqual(EndpointTypeEnum.Webrtc);
39-
expect(data.status).toEqual(EndpointStatusEnum.Connected);
40+
expect(data.status).toBeDefined();
4041
expect(data.creationTimestamp).toBeDefined();
4142

4243
endpointId = data.endpointId;
@@ -45,13 +46,13 @@ describe('EndpointsApi', () => {
4546

4647
test('should create multiple endpoints', async () => {
4748
const endpointBody1: CreateWebRtcConnectionRequest = {
48-
name: 'Test Endpoint 1',
49-
displayName: 'Test WebRTC Endpoint 1'
49+
type: EndpointTypeEnum.Webrtc,
50+
direction: EndpointDirectionEnum.Bidirectional
5051
};
5152

5253
const endpointBody2: CreateWebRtcConnectionRequest = {
53-
name: 'Test Endpoint 2',
54-
displayName: 'Test WebRTC Endpoint 2'
54+
type: EndpointTypeEnum.Webrtc,
55+
direction: EndpointDirectionEnum.Bidirectional
5556
};
5657

5758
const { status: status1, data: data1 } = await endpointsApi.createEndpoint(BW_ACCOUNT_ID, endpointBody1);
@@ -155,8 +156,8 @@ describe('EndpointsApi', () => {
155156
test('should delete an endpoint', async () => {
156157
// Create an endpoint to delete
157158
const endpointBody: CreateWebRtcConnectionRequest = {
158-
name: 'Endpoint to Delete',
159-
displayName: 'Test WebRTC Endpoint to Delete'
159+
type: EndpointTypeEnum.Webrtc,
160+
direction: EndpointDirectionEnum.Bidirectional
160161
};
161162

162163
const { data: createdData } = await endpointsApi.createEndpoint(BW_ACCOUNT_ID, endpointBody);
@@ -194,7 +195,7 @@ describe('EndpointsApi', () => {
194195
}
195196
});
196197

197-
test('403 - Forbidden with unauthorized account', async () => {
198+
test('404 - Not Found with invalid account', async () => {
198199
const configBad = new Configuration({
199200
clientId: BW_CLIENT_ID,
200201
clientSecret: BW_CLIENT_SECRET
@@ -205,7 +206,7 @@ describe('EndpointsApi', () => {
205206
await endpointsApiBad.listEndpoints('invalid-account-id');
206207
fail('Expected error to be thrown');
207208
} catch (e) {
208-
expect(e.response.status).toEqual(403);
209+
expect(e.response.status).toEqual(404);
209210
}
210211
});
211212

tests/unit/models/create-endpoint-response.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ describe('CreateEndpointResponse', () => {
1818
status: EndpointStatusEnum.Connected,
1919
creationTimestamp: '2024-02-18T10:30:00Z',
2020
expirationTimestamp: '2024-02-19T10:30:00Z',
21+
token: 'xxxxx.yyyyy.zzzzz',
2122
tag: 'webrtc-endpoint'
2223
};
2324

@@ -31,6 +32,7 @@ describe('CreateEndpointResponse', () => {
3132
expect(response.data.endpointId).toBe('ep-123456');
3233
expect(response.data.type).toBe('WEBRTC');
3334
expect(response.data.status).toBe('CONNECTED');
35+
expect(response.data.token).toBe('xxxxx.yyyyy.zzzzz');
3436
expect(response.errors).toHaveLength(0);
3537
});
3638

@@ -45,7 +47,8 @@ describe('CreateEndpointResponse', () => {
4547
type: EndpointTypeEnum.Webrtc,
4648
status: EndpointStatusEnum.Disconnected,
4749
creationTimestamp: '2024-02-18T10:30:00Z',
48-
expirationTimestamp: '2024-02-19T10:30:00Z'
50+
expirationTimestamp: '2024-02-19T10:30:00Z',
51+
token: 'invalid.token.value'
4952
};
5053

5154
const error: ModelError = {

0 commit comments

Comments
 (0)