Skip to content

Commit af4aff1

Browse files
committed
Merge branch 'release-25.7' into 'main'
Release 25.8 content See merge request nwac/sdk-ts!123
2 parents 808ecd3 + fb69fc2 commit af4aff1

39 files changed

+2001
-1162
lines changed

Jenkinsfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pipeline {
5454
environment {
5555
NAC_TOKEN = credentials('NAC_TOKEN')
5656
NAC_TOKEN_PROD = credentials('NAC_TOKEN_PROD')
57+
NAC_TOKEN_STAGE = credentials('NAC_TOKEN_STAGE')
5758
TEAMS_WEBHOOK = credentials('TEAMS_WEBHOOK')
5859
NPM_AUTH_TOKEN = credentials('NPM_AUTH_TOKEN')
5960
SDK_NOTIFICATION_SERVER_URL = credentials('SDK_NOTIFICATION_SERVER_URL')
@@ -180,7 +181,7 @@ pipeline {
180181
"""
181182
if(env.gitlabActionType == "TAG_PUSH" && env.gitlabBranch.contains("rc-")){
182183
sh '''
183-
PRODTEST=1 http_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" https_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" npm run integration
184+
NAC_ENV=staging http_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" https_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" npm run integration
184185
'''
185186
}
186187
}
@@ -199,7 +200,7 @@ pipeline {
199200
"""
200201
if(env.gitlabActionType == "TAG_PUSH" && env.gitlabBranch.contains("release-")){
201202
sh '''
202-
PRODTEST=1 http_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" https_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" npm run integration
203+
NAC_ENV=staging http_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" https_proxy="http://fihel1d-proxy.emea.nsn-net.net:8080" npm run integration
203204
'''
204205
}
205206
}

examples/call-forwarding-signal.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { NetworkAsCodeClient } from "network-as-code";
2+
3+
// We begin by creating a Network as Code client
4+
const client = new NetworkAsCodeClient("<your-application-key-here>");
5+
6+
// Then, create a device object for the phone number you want to check
7+
const myDevice = client.devices.get({
8+
// The phone number accepts the "+" sign, but not spaces or "()" marks
9+
phoneNumber: "+367123456"
10+
});
11+
12+
// Verify, if a device has an active, unconditional call forwarding
13+
const result = await myDevice.verifyUnconditionalForwarding()
14+
15+
// Show the result
16+
console.log(result)
17+
18+
// To get information about an active "call forwarding setup" for the given device,
19+
// use the following snippet:
20+
const services = await myDevice.getCallForwarding()
21+
22+
// Show active Call Forwarding Services
23+
console.log(services)

examples/location-retrieval.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const location = await myDevice.getLocation(3600);
2727

2828
console.log(location.latitude);
2929
console.log(location.longitude);
30-
console.log(location.civicAddress);
3130

3231
// For estimations, use the `verifyLocation()` method
3332
// with the geo-coordinates and maximum age in seconds.

installation-test/installation-test.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@ import { NetworkAsCodeClient } from "network-as-code";
44

55
const main = async () => {
66
const NAC_TOKEN = process.env["NAC_TOKEN"];
7-
const client = new NetworkAsCodeClient(NAC_TOKEN, true);
7+
const client = new NetworkAsCodeClient(NAC_TOKEN, "dev");
88

99
let device = client.devices.get({
10-
networkAccessIdentifier: "[email protected]",
11-
ipv4Address: {
12-
publicAddress: "1.1.1.2",
13-
privateAddress: "1.1.1.2",
14-
publicPort: 80,
15-
},
10+
phoneNumber: "+36719991001"
1611
});
1712

1813
let location = await device.getLocation();

installation-test/installation-test.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,17 @@
33
import { NetworkAsCodeClient } from "network-as-code";
44

55
test("nac", async () => {
6-
const NAC_TOKEN = process.env["NAC_TOKEN"];
7-
const client = new NetworkAsCodeClient(NAC_TOKEN as string, true);
6+
const NAC_TOKEN = process.env["NAC_TOKEN"];
7+
const client = new NetworkAsCodeClient(NAC_TOKEN as string, "dev");
88

9-
let device = client.devices.get({
10-
networkAccessIdentifier: "[email protected]",
11-
ipv4Address: {
12-
publicAddress: "1.1.1.2",
13-
privateAddress: "1.1.1.2",
14-
publicPort: 80,
15-
},
16-
});
9+
let device = client.devices.get({
10+
phoneNumber: "+36719991001"
11+
});
1712

18-
let location = await device.getLocation();
13+
let location = await device.getLocation();
1914

20-
expect(location).toBeDefined();
15+
expect(location).toBeDefined();
2116

22-
expect(location.latitude).toBe(47.48627616952785);
23-
expect(location.longitude).toBe(19.07915612501993);
17+
expect(location.latitude).toBe(47.48627616952785);
18+
expect(location.longitude).toBe(19.07915612501993);
2419
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { beforeAll, describe, expect } from "@jest/globals";
2+
import "dotenv/config";
3+
import { NetworkAsCodeClient } from "../src";
4+
import { configureClient } from "./configClient";
5+
6+
let client: NetworkAsCodeClient;
7+
8+
beforeAll((): any => {
9+
client = configureClient()
10+
});
11+
12+
describe("Call forwarding retrieval and verification of unconditional forwarding", () => {
13+
it("should check if device is unconditionally forwarding a call", async () => {
14+
let device = client.devices.get({
15+
phoneNumber: "+99999991111"
16+
});
17+
18+
let response = await device.verifyUnconditionalForwarding()
19+
expect(response).toBe(true)
20+
});
21+
22+
it("should check if device is not unconditionally forwarding a call", async () => {
23+
let device = client.devices.get({
24+
phoneNumber: "+999999991001"
25+
});
26+
27+
let response = await device.verifyUnconditionalForwarding()
28+
expect(response).toBe(false)
29+
})
30+
31+
it("gets list of call forwarding services", async () => {
32+
let device = client.devices.get({
33+
phoneNumber: "+999999991111"
34+
});
35+
36+
let response = await device.getCallForwarding()
37+
let types = ['inactive', 'unconditional', 'conditional_busy', 'conditional_not_reachable', 'conditional_no_answer']
38+
39+
expect(response instanceof Array).toBeTruthy();
40+
expect(response.every((val) => types.includes(val)));
41+
});
42+
43+
});

integration-tests/configClient.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@ import "dotenv/config";
44
import { NetworkAsCodeClient } from "../src";
55

66
export const configureClient = (): NetworkAsCodeClient => {
7-
const prodTest = process.env["PRODTEST"];
8-
const NAC_TOKEN = prodTest ? process.env["NAC_TOKEN_PROD"] : process.env["NAC_TOKEN"];
9-
const client = new NetworkAsCodeClient(
10-
NAC_TOKEN as string,
11-
prodTest ? false : true
12-
);
13-
return client;
7+
const nacEnv = process.env["NAC_ENV"];
8+
9+
let NAC_TOKEN = process.env["NAC_TOKEN"];
10+
11+
if (nacEnv === "prod") {
12+
NAC_TOKEN = process.env["NAC_TOKEN_PROD"];
13+
} else if (nacEnv === "staging") {
14+
NAC_TOKEN = process.env["NAC_TOKEN_STAGE"];
15+
}
16+
17+
const client = new NetworkAsCodeClient(
18+
NAC_TOKEN as string,
19+
nacEnv ? nacEnv : "dev"
20+
);
21+
return client;
1422
}
1523

1624
export const configureNotificationServerUrl = () : string => {

integration-tests/congestionInsights.itest.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("Congestion Insights", () => {
2424
const expirationDate = new Date(Date.now() + 5 * 60 * 1000);
2525
expirationDate.setMilliseconds(0);
2626

27-
it.skip("can create subscription for congestion insights", async () => {
27+
it("can create subscription for congestion insights", async () => {
2828
const notificationId: string = uuid();
2929
const subscription = await client.insights.subscribeToCongestionInfo(
3030
device,
@@ -36,9 +36,9 @@ describe("Congestion Insights", () => {
3636
expect(subscription.expiresAt).toEqual(
3737
new Date(expirationDate.toISOString().replace(".000", ""))
3838
);
39-
39+
// Fetching the subscription notification
4040
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
41-
let notification = await fetch(`${notificationUrl}/congestion-insights/get/${notificationId}`,
41+
let notification = await fetch(`${notificationUrl}/congestion-insights/${notificationId}`,
4242
{
4343
method: "GET",
4444
agent: agent
@@ -49,7 +49,8 @@ describe("Congestion Insights", () => {
4949

5050
expect(data).not.toBeNull();
5151

52-
notification = await fetch(`${notificationUrl}/congestion-insights/delete/${notificationId}`,
52+
// Deleting the subscription notification
53+
notification = await fetch(`${notificationUrl}/congestion-insights/${notificationId}`,
5354
{
5455
method: 'DELETE',
5556
agent: agent
@@ -62,7 +63,7 @@ describe("Congestion Insights", () => {
6263

6364
},20 * 1000);
6465

65-
it.skip("can create subscription for congestion insights without auth token", async () => {
66+
it("can create subscription for congestion insights without auth token", async () => {
6667
const notificationId: string = uuid();
6768
const subscription = await client.insights.subscribeToCongestionInfo(
6869
device,
@@ -74,9 +75,9 @@ describe("Congestion Insights", () => {
7475
new Date(expirationDate.toISOString().replace(".000", ""))
7576
);
7677

77-
78+
// Fetching the subscription notification
7879
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
79-
let notification = await fetch(`${notificationUrl}/congestion-insights/get/${notificationId}`,
80+
let notification = await fetch(`${notificationUrl}/congestion-insights/${notificationId}`,
8081
{
8182
method: "GET",
8283
agent: agent
@@ -87,7 +88,8 @@ describe("Congestion Insights", () => {
8788

8889
expect(data).not.toBeNull();
8990

90-
notification = await fetch(`${notificationUrl}/congestion-insights/delete/${notificationId}`,
91+
// Deleting the subscription notification
92+
notification = await fetch(`${notificationUrl}/congestion-insights/${notificationId}`,
9193
{
9294
method: 'DELETE',
9395
agent: agent
@@ -100,7 +102,7 @@ describe("Congestion Insights", () => {
100102

101103
},20 * 1000);
102104

103-
it.skip("can get a subscription by id", async () => {
105+
it("can get a subscription by id", async () => {
104106
const subscription = await client.insights.subscribeToCongestionInfo(
105107
device,
106108
expirationDate,
@@ -118,7 +120,7 @@ describe("Congestion Insights", () => {
118120
await subscription.delete();
119121
});
120122

121-
it.skip("can get subscription start and expiration", async () => {
123+
it("can get subscription start and expiration", async () => {
122124
const subscription = await client.insights.subscribeToCongestionInfo(
123125
device,
124126
expirationDate,
@@ -133,7 +135,7 @@ describe("Congestion Insights", () => {
133135
await subscription.delete();
134136
});
135137

136-
it.skip("can get start and expiration from selected subscription", async () => {
138+
it("can get start and expiration from selected subscription", async () => {
137139
const subscription = await client.insights.subscribeToCongestionInfo(
138140
device,
139141
expirationDate,
@@ -155,7 +157,7 @@ describe("Congestion Insights", () => {
155157
await subscription.delete();
156158
});
157159

158-
it.skip("can get a list of subscriptions", async () => {
160+
it("can get a list of subscriptions", async () => {
159161
const subscription = await client.insights.subscribeToCongestionInfo(
160162
device,
161163
expirationDate,
@@ -176,7 +178,7 @@ describe("Congestion Insights", () => {
176178
await subscription.delete();
177179
});
178180

179-
it.skip("should fetch current congestion level relevant to a given device", async () => {
181+
it("should fetch current congestion level relevant to a given device", async () => {
180182
const subscription = await client.insights.subscribeToCongestionInfo(
181183
device,
182184
expirationDate,
@@ -203,7 +205,7 @@ describe("Congestion Insights", () => {
203205
await subscription.delete();
204206
});
205207

206-
it.skip("should fetch prediction/historical data between two time stamps:", async () => {
208+
it("should fetch prediction/historical data between two time stamps:", async () => {
207209
const subscription = await client.insights.subscribeToCongestionInfo(
208210
device,
209211
expirationDate,

0 commit comments

Comments
 (0)