Skip to content

Commit d883f76

Browse files
Blanca Rosasjaolanlo
authored andcommitted
fix: postman collection
1 parent c817ed7 commit d883f76

6 files changed

Lines changed: 45 additions & 50 deletions

File tree

src/data/postgres/tables/profileProxyConfigs.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ describe('profileproxyconfig tests', () => {
1515
let profilesProxyConfigsTable: ProfileProxyConfigsTable
1616
let querySpy: SpyInstance<any>
1717
const proxyConfigs: ProfileProxyConfigs[] = [
18-
{ profileName: 'proxyConfig', priority: 1 } as any
18+
{ configName: 'proxyConfig', priority: 1 } as any
1919
]
20-
const profileName = 'profileName'
20+
const configName = 'profileName'
2121
const tenantId = 'tenantId'
2222

2323
beforeEach(() => {
@@ -31,7 +31,7 @@ describe('profileproxyconfig tests', () => {
3131
describe('Get', () => {
3232
test('should Get', async () => {
3333
querySpy.mockResolvedValueOnce({ rows: [{}], rowCount: 1 })
34-
const result = await profilesProxyConfigsTable.getProfileProxyConfigs(profileName)
34+
const result = await profilesProxyConfigsTable.getProfileProxyConfigs(configName)
3535
expect(result).toStrictEqual([{}])
3636
expect(querySpy).toBeCalledTimes(1)
3737
expect(querySpy).toBeCalledWith(
@@ -42,42 +42,42 @@ describe('profileproxyconfig tests', () => {
4242
FROM profiles_proxyconfigs
4343
WHERE profile_name = $1 and tenant_id = $2
4444
ORDER BY priority`,
45-
[profileName, '']
45+
[configName, '']
4646
)
4747
})
4848
})
4949
describe('Delete', () => {
5050
test('should Delete', async () => {
5151
querySpy.mockResolvedValueOnce({ rows: [{}], rowCount: 1 })
52-
const result = await profilesProxyConfigsTable.deleteProfileProxyConfigs(profileName)
52+
const result = await profilesProxyConfigsTable.deleteProfileProxyConfigs(configName)
5353
expect(result).toBe(true)
5454
expect(querySpy).toBeCalledTimes(1)
5555
expect(querySpy).toBeCalledWith(
5656
`
5757
DELETE
5858
FROM profiles_proxyconfigs
5959
WHERE profile_name = $1 and tenant_id = $2`,
60-
[profileName, '']
60+
[configName, '']
6161
)
6262
})
6363
test('should Delete with tenandId', async () => {
6464
querySpy.mockResolvedValueOnce({ rows: [{}], rowCount: 1 })
65-
const result = await profilesProxyConfigsTable.deleteProfileProxyConfigs(profileName, tenantId)
65+
const result = await profilesProxyConfigsTable.deleteProfileProxyConfigs(configName, tenantId)
6666
expect(result).toBe(true)
6767
expect(querySpy).toBeCalledTimes(1)
6868
expect(querySpy).toBeCalledWith(
6969
`
7070
DELETE
7171
FROM profiles_proxyconfigs
7272
WHERE profile_name = $1 and tenant_id = $2`,
73-
[profileName, tenantId]
73+
[configName, tenantId]
7474
)
7575
})
7676
})
7777
describe('Insert', () => {
7878
test('should Insert', async () => {
7979
querySpy.mockResolvedValueOnce({ rows: [{}], rowCount: 1 })
80-
const result = await profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, profileName)
80+
const result = await profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, configName)
8181
expect(result).toBe(true)
8282
expect(querySpy).toBeCalledTimes(1)
8383
expect(querySpy).toBeCalledWith(`
@@ -86,20 +86,20 @@ describe('profileproxyconfig tests', () => {
8686
VALUES ('proxyConfig', 'profileName', '1', '')`)
8787
})
8888
test('should NOT insert when no proxyconfigs', async () => {
89-
await expect(profilesProxyConfigsTable.createProfileProxyConfigs([], profileName)).rejects.toThrow(
89+
await expect(profilesProxyConfigsTable.createProfileProxyConfigs([], configName)).rejects.toThrow(
9090
'Operation failed: profileName'
9191
)
9292
})
9393
test('should NOT insert when constraint violation', async () => {
9494
querySpy.mockRejectedValueOnce({ code: '23503', detail: 'error' })
95-
await expect(profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, profileName)).rejects.toThrow(
95+
await expect(profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, configName)).rejects.toThrow(
9696
'error'
9797
)
9898
})
9999
test('should NOT insert when unknown error', async () => {
100100
querySpy.mockRejectedValueOnce('unknown')
101-
await expect(profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, profileName)).rejects.toThrow(
102-
API_UNEXPECTED_EXCEPTION(profileName)
101+
await expect(profilesProxyConfigsTable.createProfileProxyConfigs(proxyConfigs, configName)).rejects.toThrow(
102+
API_UNEXPECTED_EXCEPTION(configName)
103103
)
104104
})
105105
})

src/data/postgres/tables/profileProxyConfigs.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export class ProfileProxyConfigsTable implements IProfileProxyConfigsTable {
1919

2020
/**
2121
* @description Get AMT Profile associated proxy configs
22-
* @param {string} profileName
22+
* @param {string} configName
2323
* @returns {ProfileProxyConfigs[]} Return an array of proxy configs
2424
*/
25-
async getProfileProxyConfigs(profileName: string, tenantId = ''): Promise<ProfileProxyConfigs[]> {
25+
async getProfileProxyConfigs(configName: string, tenantId = ''): Promise<ProfileProxyConfigs[]> {
2626
const results = await this.db.query<ProfileProxyConfigs>(
2727
`
2828
SELECT
@@ -31,20 +31,20 @@ export class ProfileProxyConfigsTable implements IProfileProxyConfigsTable {
3131
FROM profiles_proxyconfigs
3232
WHERE profile_name = $1 and tenant_id = $2
3333
ORDER BY priority`,
34-
[profileName, tenantId]
34+
[configName, tenantId]
3535
)
3636
return results.rows
3737
}
3838

3939
/**
4040
* @description Insert proxy configs associated with AMT profile
4141
* @param {ProfileProxyConfigs[]} proxyConfigs
42-
* @param {string} profileName
42+
* @param {string} configName
4343
* @returns {ProfileProxyConfigs[]} Return an array of proxy configs
4444
*/
4545
async createProfileProxyConfigs(
4646
proxyConfigs: ProfileProxyConfigs[],
47-
profileName: string,
47+
configName: string,
4848
tenantId = ''
4949
): Promise<boolean> {
5050
try {
@@ -53,8 +53,8 @@ export class ProfileProxyConfigsTable implements IProfileProxyConfigsTable {
5353
}
5454
// Preparing data for inserting multiple rows
5555
const configs = proxyConfigs.map((config) => [
56-
config.profileName,
57-
profileName,
56+
config.configName,
57+
configName,
5858
config.priority,
5959
tenantId
6060
])
@@ -77,23 +77,23 @@ export class ProfileProxyConfigsTable implements IProfileProxyConfigsTable {
7777
if (error.code === PostgresErr.C23_FOREIGN_KEY_VIOLATION) {
7878
throw new RPSError(error.detail, 'Foreign key constraint violation')
7979
}
80-
throw new RPSError(API_UNEXPECTED_EXCEPTION(profileName))
80+
throw new RPSError(API_UNEXPECTED_EXCEPTION(configName))
8181
}
8282
return false
8383
}
8484

8585
/**
8686
* @description Delete proxy configs of an AMT Profile from DB by profile name
87-
* @param {string} profileName
87+
* @param {string} configName
8888
* @returns {boolean} Return true on successful deletion
8989
*/
90-
async deleteProfileProxyConfigs(profileName: string, tenantId = ''): Promise<boolean> {
90+
async deleteProfileProxyConfigs(configName: string, tenantId = ''): Promise<boolean> {
9191
const deleteProfileWifiResults = await this.db.query(
9292
`
9393
DELETE
9494
FROM profiles_proxyconfigs
9595
WHERE profile_name = $1 and tenant_id = $2`,
96-
[profileName, tenantId]
96+
[configName, tenantId]
9797
)
9898

9999
if (deleteProfileWifiResults?.rowCount) {

src/data/postgres/tables/proxyConfigs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('proxy configs tests', () => {
2424
let proxyConfigsTable: ProxyConfigsTable
2525
let querySpy: SpyInstance<any>
2626
let proxyConfig: ProxyConfig
27-
const accessInfo = 'profileName'
27+
const accessInfo = 'proxyName'
2828
beforeEach(() => {
2929
proxyConfig = {
3030
accessInfo: 'proxy.com',

src/models/RCS.Config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,6 @@ export interface ProxyConfig {
312312

313313
export interface ProfileProxyConfigs {
314314
priority: number
315-
profileName: string
315+
configName: string
316316
tenantId: string
317317
}

src/routes/admin/profiles/amtProfileValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ const validatewifiConfigs = async (value: any, req: Request): Promise<string[]>
201201
const validateProxyConfigs = async (value: any, req: Request): Promise<string[]> => {
202202
const proxyConfigNames: string[] = []
203203
for (const config of value) {
204-
const isProxyExist = await req.db.proxyConfigs.checkProfileExits(config.profileName, req.tenantId)
204+
const isProxyExist = await req.db.proxyConfigs.checkProfileExits(config.configName, req.tenantId)
205205
if (!isProxyExist) {
206-
proxyConfigNames.push(config.profileName)
206+
proxyConfigNames.push(config.configName)
207207
}
208208
}
209209
return proxyConfigNames

src/test/collections/rps.postman_collection.json

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info": {
3-
"_postman_id": "624f891e-336b-43c1-ac70-1c133ee328c9",
3+
"_postman_id": "b08b48b6-9b34-4497-9929-f070c6cbe104",
44
"name": "RPS API Tests",
55
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
66
"_exporter_id": "35155358"
@@ -9148,7 +9148,7 @@
91489148
"name": "AMT Profiles w/ Proxy Profiles",
91499149
"item": [
91509150
{
9151-
"name": "Create Proxy (http)",
9151+
"name": "Create Proxy (proxy-abc)",
91529152
"event": [
91539153
{
91549154
"listen": "test",
@@ -9212,7 +9212,7 @@
92129212
"response": []
92139213
},
92149214
{
9215-
"name": "Create Proxy (https)",
9215+
"name": "Create Proxy (proxy-abc.test)",
92169216
"event": [
92179217
{
92189218
"listen": "test",
@@ -9312,7 +9312,7 @@
93129312
],
93139313
"body": {
93149314
"mode": "raw",
9315-
"raw": "{\r\n \"profileName\": \"wifi-profile\",\r\n \"amtPassword\": \"Intel123!\",\r\n \"mebxPassword\": \"Intel123!\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"tag1\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"profileName\": \"proxy\"\r\n }\r\n ]\r\n}",
9315+
"raw": "{\r\n \"profileName\": \"wifi-profile\",\r\n \"amtPassword\": \"Intel123!\",\r\n \"mebxPassword\": \"Intel123!\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"tag1\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"configName\": \"proxy\"\r\n }\r\n ]\r\n}",
93169316
"options": {
93179317
"raw": {
93189318
"language": "json"
@@ -9356,9 +9356,9 @@
93569356
" pm.expect(result.dhcpEnabled).to.equal(true)\r",
93579357
" pm.expect(result.proxyConfigs.length).to.equal(2)\r",
93589358
" pm.expect(result.proxyConfigs[0].priority).to.equal(1)\r",
9359-
" pm.expect(result.proxyConfigs[0].profileName).to.equal(\"http\")\r",
9359+
" pm.expect(result.proxyConfigs[0].configName).to.equal(\"www.proxy-abc.com\")\r",
93609360
" pm.expect(result.proxyConfigs[1].priority).to.equal(2)\r",
9361-
" pm.expect(result.proxyConfigs[1].profileName).to.equal(\"https\")\r",
9361+
" pm.expect(result.proxyConfigs[1].configName).to.equal(\"www.proxy-abc.test.com\")\r",
93629362
"});"
93639363
],
93649364
"type": "text/javascript",
@@ -9383,7 +9383,12 @@
93839383
],
93849384
"body": {
93859385
"mode": "raw",
9386-
"raw": "{\r\n \"profileName\": \"wifi-profile1\",\r\n \"amtPassword\": \"P@ssw0rd\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"acm\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"profileName\": \"http\"\r\n },\r\n {\r\n \"priority\": 2,\r\n \"profileName\": \"https\"\r\n }\r\n ]\r\n}"
9386+
"raw": "{\r\n \"profileName\": \"wifi-profile1\",\r\n \"amtPassword\": \"P@ssw0rd\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"acm\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"configName\": \"www.proxy-abc.com\"\r\n },\r\n {\r\n \"priority\": 2,\r\n \"configName\": \"www.proxy-abc.test.com\"\r\n }\r\n ]\r\n}",
9387+
"options": {
9388+
"raw": {
9389+
"language": "json"
9390+
}
9391+
}
93879392
},
93889393
"url": {
93899394
"raw": "{{protocol}}://{{host}}/api/v1/admin/profiles/",
@@ -9422,7 +9427,7 @@
94229427
" pm.expect(result.dhcpEnabled).to.equal(true)\r",
94239428
" pm.expect(result.proxyConfigs.length).to.equal(1)\r",
94249429
" pm.expect(result.proxyConfigs[0].priority).to.equal(1)\r",
9425-
" pm.expect(result.proxyConfigs[0].profileName).to.equal(\"http\")\r",
9430+
" pm.expect(result.proxyConfigs[0].configName).to.equal(\"www.proxy-abc.com\")\r",
94269431
"});"
94279432
],
94289433
"type": "text/javascript",
@@ -9447,7 +9452,7 @@
94479452
],
94489453
"body": {
94499454
"mode": "raw",
9450-
"raw": "{\r\n \"profileName\": \"wifi-profile2\",\r\n \"amtPassword\": \"P@ssw0rd\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"acm\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"profileName\": \"http\"\r\n }\r\n ]\r\n}",
9455+
"raw": "{\r\n \"profileName\": \"wifi-profile2\",\r\n \"amtPassword\": \"P@ssw0rd\",\r\n \"activation\": \"ccmactivate\",\r\n \"tags\": [\"acm\"],\r\n \"dhcpEnabled\": true,\r\n \"proxyConfigs\": [\r\n {\r\n \"priority\": 1,\r\n \"configName\": \"www.proxy-abc.com\"\r\n }\r\n ]\r\n}",
94519456
"options": {
94529457
"raw": {
94539458
"language": "json"
@@ -9504,7 +9509,7 @@
95049509
" pm.expect(result[1].tags.length).to.equal(1)\r",
95059510
" pm.expect(result[1].proxyConfigs.length).to.equal(1)\r",
95069511
" pm.expect(result[1].proxyConfigs[0].priority).to.equal(1)\r",
9507-
" pm.expect(result[1].proxyConfigs[0].profileName).to.equal(\"http\")\r",
9512+
" pm.expect(result[1].proxyConfigs[0].configName).to.equal(\"www.proxy-abc.com\")\r",
95089513
"});"
95099514
],
95109515
"type": "text/javascript",
@@ -12949,16 +12954,6 @@
1294912954
{
1295012955
"name": "Create Duplicate Proxy",
1295112956
"event": [
12952-
{
12953-
"listen": "prerequest",
12954-
"script": {
12955-
"exec": [
12956-
""
12957-
],
12958-
"type": "text/javascript",
12959-
"packages": {}
12960-
}
12961-
},
1296212957
{
1296312958
"listen": "test",
1296412959
"script": {
@@ -12969,7 +12964,7 @@
1296912964
"pm.test(\"Request should return an error message\", function () {\r",
1297012965
" var jsonData = pm.response.json();\r",
1297112966
" pm.expect(jsonData.error).to.eql(\"Unique key violation\");\r",
12972-
" pm.expect(jsonData.message).to.eql(\"Proxy profile P1 already exists\");\r",
12967+
" pm.expect(jsonData.message).to.eql(\"Proxy profile www.vprodemo.com already exists\");\r",
1297312968
"});"
1297412969
],
1297512970
"type": "text/javascript",
@@ -12985,7 +12980,7 @@
1298512980
"header": [],
1298612981
"body": {
1298712982
"mode": "raw",
12988-
"raw": "{\r\n \"accessInfo\": \"192.168.9.58\",\r\n \"infoFormat\": 3,\r\n \"port\": 900,\r\n \"networkDnsSuffix\": \"intel.com\"\r\n}",
12983+
"raw": "{\r\n \"accessInfo\": \"www.vprodemo.com\",\r\n \"infoFormat\": 201,\r\n \"port\": 900,\r\n \"networkDnsSuffix\": \"intel.com\"\r\n}",
1298912984
"options": {
1299012985
"raw": {
1299112986
"language": "json"

0 commit comments

Comments
 (0)