Skip to content

Commit 4c31d44

Browse files
committed
Merge branch 'release-25.6' into 'main'
Release 25.6 See merge request nwac/sdk-ts!108
2 parents 748e6c9 + de3126d commit 4c31d44

23 files changed

+375
-587
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## Version 5.0.0
4+
5+
Breaking Changes:
6+
- Introduced one main API with all features available as separate endpoints.
7+
8+
Deprications:
9+
- Slice modification endpoint is no longer supported.
10+
311
## Version 4.2.1
412

513
Fixes:

integration-tests/congestionInsights.itest.ts

Lines changed: 109 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,106 @@
11
import { NetworkAsCodeClient } from "../src";
22
import "dotenv/config";
33
import { Device } from "../src/models/device";
4-
import { configureClient } from "./configClient";
4+
import { configureClient, configureNotificationServerUrl } from "./configClient";
5+
import { ProxyAgent } from "proxy-agent";
6+
import fetch from "node-fetch";
7+
import { v4 as uuid } from 'uuid';
58

69
let client: NetworkAsCodeClient;
710
let device: Device;
11+
let notificationUrl: string;
12+
let agent : ProxyAgent
813

914
beforeAll(() => {
1015
client = configureClient()
1116
device = client.devices.get({
12-
phoneNumber: "+3672123456",
17+
phoneNumber: "+3670123456",
1318
});
19+
notificationUrl = configureNotificationServerUrl();
20+
agent = new ProxyAgent();
1421
});
1522

1623
describe("Congestion Insights", () => {
1724
const expirationDate = new Date(Date.now() + 5 * 60 * 1000);
1825
expirationDate.setMilliseconds(0);
1926

20-
it.skip("can create subscription for congestion insights", async () => {
27+
it("can create subscription for congestion insights", async () => {
28+
const notificationId: string = uuid();
2129
const subscription = await client.insights.subscribeToCongestionInfo(
2230
device,
2331
expirationDate,
24-
"https://example.com/notify",
32+
`${notificationUrl}/notify/${notificationId}`,
2533
"c8974e592c2fa383d4a3960714"
2634
);
2735

2836
expect(subscription.expiresAt).toEqual(
2937
new Date(expirationDate.toISOString().replace(".000", ""))
38+
);
39+
40+
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
41+
let notification = await fetch(`${notificationUrl}/congestion-insights/get/${notificationId}`,
42+
{
43+
method: "GET",
44+
agent: agent
45+
}
3046
);
3147

32-
subscription.delete();
33-
});
48+
const data = await notification.json();
49+
50+
expect(data).not.toBeNull();
51+
52+
notification = await fetch(`${notificationUrl}/congestion-insights/delete/${notificationId}`,
53+
{
54+
method: 'DELETE',
55+
agent: agent
56+
});
57+
58+
const deletionData = await notification.json()
59+
expect(deletionData).toEqual([{"message": "Notification deleted"}, 200])
3460

35-
it.skip("can create subscription for congestion insights without auth token", async () => {
61+
await subscription.delete();
62+
63+
},20 * 1000);
64+
65+
it("can create subscription for congestion insights without auth token", async () => {
66+
const notificationId: string = uuid();
3667
const subscription = await client.insights.subscribeToCongestionInfo(
3768
device,
3869
expirationDate,
39-
"https://example.com/notify"
70+
`${notificationUrl}/notify/${notificationId}`
4071
);
4172

4273
expect(subscription.expiresAt).toEqual(
4374
new Date(expirationDate.toISOString().replace(".000", ""))
4475
);
76+
77+
78+
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
79+
let notification = await fetch(`${notificationUrl}/congestion-insights/get/${notificationId}`,
80+
{
81+
method: "GET",
82+
agent: agent
83+
}
84+
);
4585

46-
subscription.delete();
47-
});
86+
const data = await notification.json();
4887

49-
it.skip("can get a subscription by id", async () => {
88+
expect(data).not.toBeNull();
89+
90+
notification = await fetch(`${notificationUrl}/congestion-insights/delete/${notificationId}`,
91+
{
92+
method: 'DELETE',
93+
agent: agent
94+
});
95+
96+
const deletionData = await notification.json()
97+
expect(deletionData).toEqual([{"message": "Notification deleted"}, 200])
98+
99+
await subscription.delete();
100+
101+
},20 * 1000);
102+
103+
it("can get a subscription by id", async () => {
50104
const subscription = await client.insights.subscribeToCongestionInfo(
51105
device,
52106
expirationDate,
@@ -61,10 +115,47 @@ describe("Congestion Insights", () => {
61115
expect(subscription2.subscriptionId).toBe(subscription.subscriptionId);
62116
expect(subscription2.startsAt).toEqual(subscription.startsAt);
63117

64-
subscription.delete();
118+
await subscription.delete();
119+
});
120+
121+
it("can get subscription start and expiration", async () => {
122+
const subscription = await client.insights.subscribeToCongestionInfo(
123+
device,
124+
expirationDate,
125+
"https://example.com/notify"
126+
);
127+
128+
expect(subscription.startsAt).toBeDefined()
129+
expect(subscription.expiresAt).toBeDefined()
130+
131+
expect(subscription.startsAt instanceof Date).toBeTruthy();
132+
133+
await subscription.delete();
134+
});
135+
136+
it("can get start and expiration from selected subscription", async () => {
137+
const subscription = await client.insights.subscribeToCongestionInfo(
138+
device,
139+
expirationDate,
140+
"https://example.com/notify"
141+
);
142+
143+
const subscriptionFromList = (await client.insights.getSubscriptions())[0]
144+
145+
expect(subscriptionFromList.startsAt).toBeDefined()
146+
expect(subscriptionFromList.expiresAt).toBeDefined()
147+
148+
const subscriptionById = await client.insights.get(
149+
subscription.subscriptionId
150+
);
151+
152+
expect(subscriptionById.startsAt).toBeDefined()
153+
expect(subscriptionById.expiresAt).toBeDefined()
154+
155+
await subscription.delete();
65156
});
66157

67-
it.skip("can get a list of subscriptions", async () => {
158+
it("can get a list of subscriptions", async () => {
68159
const subscription = await client.insights.subscribeToCongestionInfo(
69160
device,
70161
expirationDate,
@@ -82,10 +173,10 @@ describe("Congestion Insights", () => {
82173
).length
83174
).toBe(1);
84175

85-
subscription.delete();
176+
await subscription.delete();
86177
});
87178

88-
it.skip("should fetch current congestion level relevant to a given device", async () => {
179+
it("should fetch current congestion level relevant to a given device", async () => {
89180
const subscription = await client.insights.subscribeToCongestionInfo(
90181
device,
91182
expirationDate,
@@ -109,10 +200,10 @@ describe("Congestion Insights", () => {
109200
);
110201
});
111202

112-
subscription.delete();
203+
await subscription.delete();
113204
});
114205

115-
it.skip("should fetch prediction/historical data between two time stamps:", async () => {
206+
it("should fetch prediction/historical data between two time stamps:", async () => {
116207
const subscription = await client.insights.subscribeToCongestionInfo(
117208
device,
118209
expirationDate,
@@ -137,6 +228,6 @@ describe("Congestion Insights", () => {
137228
);
138229
});
139230

140-
subscription.delete();
231+
await subscription.delete();
141232
});
142233
});

integration-tests/geofencing.itest.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ beforeAll(() => {
2121
});
2222

2323
describe("Geofencing", () => {
24-
it.skip("should subscribe for geofencing event area entered", async () => {
24+
it("should subscribe for geofencing event area entered", async () => {
2525
const subscription = await client.geofencing.subscribe(device, {
2626
sink: `${notificationUrl}/notify`,
2727
types: ["org.camaraproject.geofencing-subscriptions.v0.area-entered"],
@@ -51,7 +51,7 @@ describe("Geofencing", () => {
5151
subscription.delete();
5252
},20 * 1000);
5353

54-
it.skip("should subscribe for geofencing event area left", async () => {
54+
it("should subscribe for geofencing event area left", async () => {
5555
const subscription = await client.geofencing.subscribe(device, {
5656
sink: `${notificationUrl}/notify`,
5757
types: ["org.camaraproject.geofencing-subscriptions.v0.area-left"],
@@ -82,7 +82,7 @@ describe("Geofencing", () => {
8282
subscription.delete();
8383
}, 20* 1000);
8484

85-
it.skip("should subscribe for geofencing event with plain credential", async () => {
85+
it("should subscribe for geofencing event with plain credential", async () => {
8686
const subscription = await client.geofencing.subscribe(device, {
8787
sink: `${notificationUrl}/notify`,
8888
types: ["org.camaraproject.geofencing-subscriptions.v0.area-left"],
@@ -118,7 +118,7 @@ describe("Geofencing", () => {
118118
subscription.delete();
119119
}, 20 * 1000);
120120

121-
it.skip("should subscribe for geofencing event with accesstoken credential", async () => {
121+
it("should subscribe for geofencing event with accesstoken credential", async () => {
122122
const expirationDate = new Date(Date.now() + 5 * 60 * 60 * 1000);
123123
expirationDate.setMilliseconds(0);
124124
const subscription = await client.geofencing.subscribe(device, {
@@ -157,7 +157,7 @@ describe("Geofencing", () => {
157157
subscription.delete();
158158
}, 20 * 1000);
159159

160-
it.skip("should get an event subscription", async () => {
160+
it("should get an event subscription", async () => {
161161
const subscription = await client.geofencing.subscribe(device, {
162162
sink: "https://example.com/notif",
163163
types: ["org.camaraproject.geofencing-subscriptions.v0.area-entered"],
@@ -175,7 +175,7 @@ describe("Geofencing", () => {
175175
subscription.delete();
176176
});
177177

178-
it.skip("should get all event subscriptions", async () => {
178+
it("should get all event subscriptions", async () => {
179179
const subscription = await client.geofencing.subscribe(device, {
180180
sink: "https://example.com/notif",
181181
types: ["org.camaraproject.geofencing-subscriptions.v0.area-entered"],
@@ -193,7 +193,7 @@ describe("Geofencing", () => {
193193
subscription.delete();
194194
});
195195

196-
it.skip("should delete an event subscription", async () => {
196+
it("should delete an event subscription", async () => {
197197
const subscription = await client.geofencing.subscribe(device, {
198198
sink: "https://example.com/notif",
199199
types: ["org.camaraproject.geofencing-subscriptions.v0.area-entered"],

integration-tests/numberVerification.itest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ describe("Number Verification authentication", () => {
3838
const credentials: any = await client.authentication.credentials();
3939
const endpoints: any = await client.authentication.endpoints();
4040
const redirectUri= "https://example.com/redirect";
41-
const scope = "number-verification:verify";
41+
const scope = "dpv:FraudPreventionAndDetection number-verification:verify";
4242
const loginHint = "+3637123456";
4343
const callback = await client.authentication.createAuthenticationLink(
4444
redirectUri,
4545
scope,
4646
loginHint
4747
);
4848
expect(callback)
49-
.toEqual(`${endpoints.authorizationEndpoint}?response_type=code&client_id=${credentials.clientId}&redirect_uri=https%3A%2F%2Fexample.com%2Fredirect&scope=number-verification%3Averify&login_hint=%2B3637123456`);
49+
.toEqual(`${endpoints.authorizationEndpoint}?response_type=code&client_id=${credentials.clientId}&redirect_uri=https%3A%2F%2Fexample.com%2Fredirect&scope=dpv%3AFraudPreventionAndDetection%20number-verification%3Averify&login_hint=%2B3637123456`);
5050
});
5151
});
5252

5353
describe("Number Verification NaC auth code and access token", () => {
5454
it("should get NaC auth code", async () => {
5555
const redirectUri= "https://example.com/redirect";
56-
const scope = "number-verification:verify";
56+
const scope = "dpv:FraudPreventionAndDetection number-verification:verify";
5757
const loginHint = "+3637123456";
5858
const callback = await client.authentication.createAuthenticationLink(
5959
redirectUri,
@@ -85,7 +85,7 @@ describe("Number Verification NaC auth code and access token", () => {
8585

8686
it("should get single use access token", async () => {
8787
const redirectUri= "https://example.com/redirect";
88-
const scope = "number-verification:verify";
88+
const scope = "dpv:FraudPreventionAndDetection number-verification:verify";
8989
const loginHint = "+3637123456";
9090
const callback = await client.authentication.createAuthenticationLink(
9191
redirectUri,
@@ -122,7 +122,7 @@ describe("Number Verification NaC auth code and access token", () => {
122122
describe("Number verification", () => {
123123
it("should verify number", async () => {
124124
const redirectUri= "https://example.com/redirect";
125-
const scope = "number-verification:verify";
125+
const scope = "dpv:FraudPreventionAndDetection number-verification:verify";
126126
const loginHint = "+3637123456";
127127
const callback = await client.authentication.createAuthenticationLink(
128128
redirectUri,
@@ -167,7 +167,7 @@ describe("Number verification", () => {
167167
describe("Get Phone Number", () => {
168168
it("should get device phone number", async () => {
169169
const redirectUri= "https://example.com/redirect";
170-
const scope = "number-verification:device-phone-number:read";
170+
const scope = "dpv:FraudPreventionAndDetection number-verification:device-phone-number:read";
171171
const loginHint = "+3637123456";
172172
const callback = await client.authentication.createAuthenticationLink(
173173
redirectUri,

integration-tests/qos.itest.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ describe("Qos", () => {
189189

190190
expect(session.status).toEqual("REQUESTED");
191191
expect(session.profile).toEqual("QOS_M");
192+
expect(session.devicePorts?.ports).toEqual([80]);
192193
await session.deleteSession();
193194
});
194195

@@ -202,6 +203,7 @@ describe("Qos", () => {
202203

203204
expect(session.status).toEqual("REQUESTED");
204205
expect(session.profile).toEqual("QOS_M");
206+
expect(session.devicePorts?.ranges).toEqual([{ from: 80, to: 443 }]);
205207
await session.deleteSession();
206208
});
207209

0 commit comments

Comments
 (0)