added scripts and postman collections for new build

This commit is contained in:
Philip Ellis
2023-08-31 13:07:19 -05:00
parent 2ba5f25c3b
commit b6cef42870
10 changed files with 283145 additions and 3 deletions

View File

@@ -19,10 +19,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install swagger-cli
- name: Install swagger-cli and postman
run: |
npm install -g swagger-cli
npm install -g openapi-to-postmanv2
- name: Dereference Beta API Specification
run: |
swagger-cli bundle --dereference idn/sailpoint-api.beta.yaml -t yaml -o dereferenced/deref-sailpoint-api.beta.yaml
openapi2postmanv2 -s dereferenced/deref-sailpoint-api.beta.yaml -o postman/collections/sailpoint-api-beta.json -p -O folderStrategy=Tags,requestParametersResolution=Schema,exampleParametersResolution=Schema,disableOptionalParameters=true,optimizeConversion=false,stackLimit=50,alwaysInheritAuthentication=true
node postman-script/modify-collection.js postman/collections/sailpoint-api-beta.json
- uses: stefanzweifel/git-auto-commit-action@v4

View File

@@ -18,11 +18,15 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install swagger-cli
node-version: "18"
- name: Install swagger-cli and postman
run: |
npm install -g swagger-cli
npm install -g openapi-to-postmanv2
- name: Dereference API Specification
run: |
swagger-cli bundle --dereference idn/sailpoint-api.v3.yaml -t yaml -o dereferenced/deref-sailpoint-api.v3.yaml
openapi2postmanv2 -s dereferenced/deref-sailpoint-api.v3.yaml -o postman/collections/sailpoint-api-v3.json -p -O folderStrategy=Tags,requestParametersResolution=Schema,exampleParametersResolution=Schema,disableOptionalParameters=true,optimizeConversion=false,stackLimit=50,alwaysInheritAuthentication=true
node postman-script/modify-collection.js postman/collections/sailpoint-api-v3.json
- uses: stefanzweifel/git-auto-commit-action@v4

View File

@@ -0,0 +1,10 @@
{
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{accessToken}}",
"type": "string"
}
]
}

View File

@@ -0,0 +1,48 @@
const fs = require('fs');
// Function to recursively delete "auth" key from an object
const deleteAuthKey = (obj) => {
for (const key in obj) {
if (typeof obj[key] === 'object') {
deleteAuthKey(obj[key]); // Recursive call for nested objects
}
if (key === 'auth') {
delete obj[key];
}
}
};
const args = process.argv;
// Read the JSON file
fs.readFile(args[2], 'utf8', (err, data) => {
if (err) {
console.error('Error reading the file:', err);
return;
}
try {
// Parse the JSON content
const jsonObject = JSON.parse(data);
// Delete all occurrences of the key "auth"
deleteAuthKey(jsonObject);
jsonObject.auth = JSON.parse(fs.readFileSync('postman-script/base-auth.json', 'utf8'));
jsonObject.event = JSON.parse(fs.readFileSync('postman-script/pre-script.json', 'utf8'));
jsonObject.variable = JSON.parse(fs.readFileSync('postman-script/variable.json', 'utf8'));
// Write the modified JSON content back to the file
fs.writeFile(args[2], JSON.stringify(jsonObject, null, 2), (writeErr) => {
if (writeErr) {
console.error('Error writing the file:', writeErr);
} else {
console.log('Auth keys deleted and file updated successfully.');
}
});
} catch (parseError) {
console.error('Error parsing JSON:', parseError);
}
});

View File

@@ -0,0 +1,65 @@
[
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"const domain = pm.environment.get('domain') ? pm.environment.get('domain') : pm.collectionVariables.get('domain')",
"const tokenUrl = 'https://' + pm.environment.get('tenant') + '.api.' + domain + '.com/oauth/token';",
"const clientId = pm.environment.get('clientId');",
"const clientSecret = pm.environment.get('clientSecret');",
"",
"const getTokenRequest = {",
" method: 'POST',",
" url: tokenUrl,",
" body: {",
" mode: 'formdata',",
" formdata: [{",
" key: 'grant_type',",
" value: 'client_credentials'",
" },",
" {",
" key: 'client_id',",
" value: clientId",
" },",
" {",
" key: 'client_secret',",
" value: clientSecret",
" }",
" ]",
" }",
"};",
"",
"",
"var moment = require('moment');",
"if (!pm.environment.has('tokenExpTime')) {",
" pm.environment.set('tokenExpTime', moment());",
"}",
"",
"if (moment(pm.environment.get('tokenExpTime')) <= moment() || !pm.environment.get('tokenExpTime') || !pm.environment.get('accessToken')) {",
" var time = moment();",
" time.add(12, 'hours');",
" pm.environment.set('tokenExpTime', time);",
" pm.sendRequest(getTokenRequest, (err, response) => {",
" const jsonResponse = response.json();",
" if (response.code != 200) {",
" throw new Error(`Unable to authenticate: ${JSON.stringify(jsonResponse)}`);",
" }",
" const newAccessToken = jsonResponse.access_token;",
" pm.environment.set('accessToken', newAccessToken);",
" });",
"",
"}"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
]

View File

@@ -0,0 +1,12 @@
[
{
"key": "domain",
"value": "identitynow",
"type": "string"
},
{
"key": "baseUrl",
"value": "https://{{tenant}}.api.{{domain}}.com",
"type": "string"
}
]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long