Commit 81b08dc4 authored by MANISH KUMAR's avatar MANISH KUMAR
Browse files

Merge branch 'users/arysingh/AddProbeServiceCRUD' into 'master'

Changes to support probe tests service CRUD operations

See merge request !440
parents 085e93fe 80292659
Pipeline #60641 passed with stages
in 1 minute and 8 seconds
node_modules/
temp.scenarios/
.envrc
*.env
\ No newline at end of file
......@@ -9,7 +9,16 @@ module.exports = {
entitlement: `https://${process.env.OSDU_HOST}/api/entitlements/v2`,
legal: `https://${process.env.OSDU_HOST}/api/legal/v1`,
storage: `https://${process.env.OSDU_HOST}/api/storage/v2`,
search: `https://${process.env.OSDU_HOST}/api/search/v2`,
notification: `https://${process.env.OSDU_HOST}/api/notification/v1`,
partition: `https://${process.env.OSDU_HOST}/api/partition/v1`,
crs_catalog: `https://${process.env.OSDU_HOST}/api/crs/catalog`,
crs_conversion: `https://${process.env.OSDU_HOST}/api/crs/converter`,
ingestion_workflow: `https://${process.env.OSDU_HOST}/api/workflow/v1`,
policy: `https://${process.env.OSDU_HOST}/api/policy/v1`,
unit: `https://${process.env.OSDU_HOST}/api/unit/v3`,
search: `https://${process.env.OSDU_HOST}/api/search/v2/query`,
schema: `https://${process.env.OSDU_HOST}/api/schema-service/v1`,
register: `https://${process.env.OSDU_HOST}/api/register/v1`,
},
auth_params: {
grant_type: "client_credentials",
......@@ -20,5 +29,72 @@ module.exports = {
telemetry_settings: {
metrics: process.env.TRACK_METRICS,
events: process.env.TRACK_EVENTS,
}
},
subscription_id: process.env.SUBSCRIPTION_ID,
test_flags: {
crud_crs_catalog:{
getArea: true,
getCatalog: true,
getCRS: true,
},
crud_crs_conversion: {
pointConversion: true,
geoJsonConversion: false, //400 error
trajectoryConversion: true,
},
crud_entitlements: {
enableScenario: true,
},
crud_ingestion_workflow: {
getAllWorkflows: true,
createWorkflow: true,
getCreatedWorkflow: true,
},
crud_legal: {
getAllLegalTags: true,
createLegalTag: true,
getCreatedLegalTag: true,
},
crud_notification: {
createSubscription: false, // 404 error
},
crud_partition: {
preCreateGetPartition: true,
createPartition: true,
getCreatedPartition: true,
},
crud_policy: {
getAllPolicies: true,
evaluatePolicy: false, // {"code":"resource_not_found","message":"storage_not_found_error: policy id \"test\""}
createTestPolicy: false, // {"code":"resource_not_found","message":"storage_not_found_error: policy id \"test\""}
getTestPolicy: true,
},
crud_register: {
subscriptionScenario: false, // Add hard coded secret in testData/sample_register_subscription_create.json
ddmsScenario: true,
actionScenario: true,
},
crud_schema: {
getSchemaById: true,
getAllSchemas: false, // 500 error
createSchema: false, // 400 error
getCreatedSchemaById: true,
deleteSchema: true,
},
crud_search: {
standardQueries: true,
enrichedQueries: true,
seismicQueries: true,
},
crud_unit: {
getUnits: true,
getCatalog: true,
getMeasurements: true,
getUnitMaps: true,
getUnitSystems: true,
},
scenario_searchInsertedRecord: {
enableScenario: true,
},
},
};
......@@ -11,6 +11,7 @@ services:
PRINCIPAL_ID: $PRINCIPAL_ID
PRINCIPAL_SECRET: $PRINCIPAL_SECRET
CLIENT_ID: $CLIENT_ID
SUBSCRIPTION_ID: $SUBSCRIPTION_ID
OSDU_HOST: $OSDU_HOST
APPINSIGHTS_INSTRUMENTATIONKEY: $APPINSIGHTS_INSTRUMENTATIONKEY
VERSION: $VERSION
'use strict';
// Imports
const should = require('chai').Should();
const { expect } = require('chai');
const request = require("supertest");
const config = require(`${__dirname}/../config`);
const testUtils = require(`${__dirname}/../utils/testUtils`);
const telemetryUtils = require(`${__dirname}/../utils/telemetryUtils`);
const { assert } = require('console');
var isEqual = require('lodash.isequal');
// Test Setup
let scenario = "crs-catalogservice_crudOps";
const majorVersion = testUtils.between(1, 100000);
const minorVersion = testUtils.between(1, 100000);
let runId = `${majorVersion}.${minorVersion}`;
console.log(`run ID: ${runId}`);
let test = {
runId: runId,
scenario: scenario,
service: "service",
api: "api",
expectedResponse: -1,
failedTests: 0,
};
// Test Data Setup
const getAreaResponse = require(`${__dirname}/../testData/sample_crs_catalog_area_response.json`);
const getCatalogResponse = require(`${__dirname}/../testData/sample_crs_catalog_catalog_response.json`);
const getCrsResponse = require(`${__dirname}/../testData/sample_crs_catalog_crs_response.json`);
let data = "";
// Test Scenario
describe(scenario, (done) => {
let token;
before(done => {
// Get a new OAuth Token
testUtils.oAuth.post('/token')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send(config.auth_params)
.then(res => {
token = 'Bearer ' + res.body.access_token;
done();
})
.catch(err => {
done(err)
});
});
describe('Scenario: CRS Catalog Service supports CRUD operations', (done) => {
if (config.test_flags.crud_crs_catalog.getArea) {
it("Get All Area", done => {
test.service = testUtils.services.crs_catalog;
test.api = test.service.api.getArea;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.get(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.expect(test.expectedResponse)
.then(res => {
data = res.body;
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err);
});
});
it('Validate: Get All Area', () => {
test.service = testUtils.services.crs_catalog;
test.api.name = 'validate_' + test.service.api.getArea.name;
test.expectedResponse = "Valid Match";
if (isEqual(data, getAreaResponse)) {
telemetryUtils.passApiRequest(test);
expect(true).to.be.true;
} else {
telemetryUtils.failApiRequest(test, "Invalid");
console.log(`actual:${JSON.stringify(data)}`);
expect(false).to.be.true;
}
});
}
if (config.test_flags.crud_crs_catalog.getCatalog) {
it("Get All Catalog", done => {
test.service = testUtils.services.crs_catalog;
test.api = test.service.api.getCatalog;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.get(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.expect(test.expectedResponse)
.then(res => {
data = res.body;
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err);
});
});
it('Validate: Get All Catalog', () => {
test.service = testUtils.services.crs_catalog;
test.api.name = 'validate_' + test.service.api.getCatalog.name;
test.expectedResponse = "Valid Match";
if (isEqual(data, getCatalogResponse)) {
telemetryUtils.passApiRequest(test);
expect(true).to.be.true;
} else {
telemetryUtils.failApiRequest(test, "Invalid");
console.log(`actual:${JSON.stringify(data)}`);
expect(false).to.be.true;
}
});
}
if (config.test_flags.crud_crs_catalog.getCRS) {
it("Get All CRS", done => {
test.service = testUtils.services.crs_catalog;
test.api = test.service.api.getCrs;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.get(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.expect(test.expectedResponse)
.then(res => {
data = res.body;
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err);
});
});
it('Validate: Get All CRS', () => {
test.service = testUtils.services.crs_catalog;
test.api.name = 'validate_' + test.service.api.getCrs.name;
test.expectedResponse = "Valid Match";
if (isEqual(data, getCrsResponse)) {
telemetryUtils.passApiRequest(test);
expect(true).to.be.true;
} else {
telemetryUtils.failApiRequest(test, "Invalid");
console.log(`actual:${JSON.stringify(data)}`);
expect(false).to.be.true;
}
});
}
afterEach(function() {
if (this.currentTest.state === 'failed') {
test.failedTests += 1;
}
});
after(done => {
telemetryUtils.scenarioRequest(runId, testUtils.services.crs_catalog, scenario, test.failedTests);
done();
});
});
});
\ No newline at end of file
'use strict';
// Imports
const should = require('chai').Should();
const { expect } = require('chai');
const request = require("supertest");
const config = require(`${__dirname}/../config`);
const testUtils = require(`${__dirname}/../utils/testUtils`);
const telemetryUtils = require(`${__dirname}/../utils/telemetryUtils`);
const { assert } = require('console');
var isEqual = require('lodash.isequal');
// Test Setup
let scenario = "crs-conversionservice_crudOps";
const majorVersion = testUtils.between(1, 100000);
const minorVersion = testUtils.between(1, 100000);
let runId = `${majorVersion}.${minorVersion}`;
console.log(`run ID: ${runId}`);
let test = {
runId: runId,
scenario: scenario,
service: "service",
api: "api",
expectedResponse: -1,
failedTests: 0,
};
// Test Data Setup
const sample_crs_basic = require(`${__dirname}/../testData/sample_crs_basic.json`);
const sample_crs_geojson = require(`${__dirname}/../testData/sample_crs_geojson.json`);
const sample_crs_point_converted = require(`${__dirname}/../testData/sample_crs_point_conversion_response.json`);
const sample_crs_trajectory_converted = require(`${__dirname}/../testData/sample_crs_trajectory_conversion_response.json`);
let data = "";
// Test Scenario
describe(scenario, (done) => {
let token;
before(done => {
// Get a new OAuth Token
testUtils.oAuth.post('/token')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send(config.auth_params)
.then(res => {
token = 'Bearer ' + res.body.access_token;
done();
})
.catch(err => {
done(err)
});
});
describe('Scenario: CRS Conversion Service supports CRUD operations', (done) => {
if (config.test_flags.crud_crs_conversion.pointConversion) {
it("CRS Point Conversion", done => {
test.service = testUtils.services.crs_conversion;
test.api = test.service.api.convert;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.post(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.send(sample_crs_basic)
.then(res => {
test.expectedResponse.should.be.an('array').that.includes(res.statusCode);
data = res.body;
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err)
});
});
it('Validate: CRS Point Conversion', () => {
test.service = testUtils.services.crs_conversion;
test.api.name = 'validate_' + test.service.api.convert.name;
test.expectedResponse = "Valid Match";
if (isEqual(data, sample_crs_point_converted)) {
telemetryUtils.passApiRequest(test);
expect(true).to.be.true;
} else {
telemetryUtils.failApiRequest(test, "Invalid");
console.log(`actual:${JSON.stringify(data)}`);
expect(false).to.be.true;
}
});
}
if (config.test_flags.crud_crs_conversion.geoJsonConversion) {
it("CRS GeoJson Conversion", done => {
test.service = testUtils.services.crs_conversion;
test.api = test.service.api.convertGeoJson;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.post(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.send(sample_crs_geojson)
.then(res => {
test.expectedResponse.should.be.an('array').that.includes(res.statusCode);
console.log(`CRS_geoJson:${JSON.stringify(res.body)}`); // Add response validation
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err)
});
});
// Add Response Validation
}
if (config.test_flags.crud_crs_conversion.trajectoryConversion) {
it("CRS Trajectory Conversion", done => {
test.service = testUtils.services.crs_conversion;
test.api = test.service.api.convertTrajectory;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.post(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.send(sample_crs_geojson)
.then(res => {
test.expectedResponse.should.be.an('array').that.includes(res.statusCode);
data = res.body;
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err)
});
});
it('Validate: CRS Trajectory Conversion', () => {
test.service = testUtils.services.crs_conversion;
test.api.name = 'validate_' + test.service.api.convertTrajectory.name;
test.expectedResponse = "Valid Match";
if (isEqual(data, sample_crs_trajectory_converted)) {
telemetryUtils.passApiRequest(test);
expect(true).to.be.true;
} else {
telemetryUtils.failApiRequest(test, "Invalid");
console.log(`actual:${JSON.stringify(data)}`);
expect(false).to.be.true;
}
});
}
afterEach(function() {
if (this.currentTest.state === 'failed') {
test.failedTests += 1;
}
});
after(done => {
telemetryUtils.scenarioRequest(runId, testUtils.services.crs_conversion, scenario, test.failedTests);
done();
});
});
});
\ No newline at end of file
This diff is collapsed.
'use strict';
// Imports
const should = require('chai').Should();
const { expect } = require('chai');
const request = require("supertest");
const config = require(`${__dirname}/../config`);
const testUtils = require(`${__dirname}/../utils/testUtils`);
const telemetryUtils = require(`${__dirname}/../utils/telemetryUtils`);
const { assert } = require('console');
var isEqual = require('lodash.isequal');
// Test Setup
let scenario = "ingestion-workflowservice_crudOps";
const majorVersion = testUtils.between(1, 100000);
const minorVersion = testUtils.between(1, 100000);
let runId = `${majorVersion}.${minorVersion}`;
console.log(`run ID: ${runId}`);
let test = {
runId: runId,
scenario: scenario,
service: "service",
api: "api",
expectedResponse: -1,
failedTests: 0,
};
// Test Data Setup
const sampleIngestionWorkflow = require(`${__dirname}/../testData/sample_ingestion_workflow.json`);
const sampleIngestionWorkflowResponse = require(`${__dirname}/../testData/sample_ingestion_workflow_response.json`);
let workflow_name = 'Default_ingest';
sampleIngestionWorkflow.workflowName = workflow_name;
let data = "";
// Test Scenario
describe(scenario, (done) => {
let token;
before(done => {
// Get a new OAuth Token
testUtils.oAuth.post('/token')
.set('Content-Type', 'application/x-www-form-urlencoded')
.send(config.auth_params)
.then(res => {
token = 'Bearer ' + res.body.access_token;
done();
})
.catch(err => {
done(err)
});
});
describe('Scenario: Ingestion Workflow Service supports CRUD operations', (done) => {
if (config.test_flags.crud_ingestion_workflow.getAllWorkflows) {
it("Get All Ingestion Workflows", done => {
test.service = testUtils.services.ingestion_workflow;
test.api = test.service.api.getAllWorkflows;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.get(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.expect(test.expectedResponse)
.then(res => {
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err);
});
});
}
if (config.test_flags.crud_ingestion_workflow.createWorkflow) {
it("Create Ingestion Workflow", done => {
test.service = testUtils.services.ingestion_workflow;
test.api = test.service.api.createWorkflow;
test.expectedResponse = test.api.expectedResponse;
test.service.host
.post(test.api.path)
.set('Authorization', token)
.set('data-partition-id', testUtils.partition)
.send(sampleIngestionWorkflow)
.then(res => {
test.expectedResponse.should.be.an('array').that.includes(res.statusCode);
telemetryUtils.passApiRequest(test);
done();
})
.catch(err => {
telemetryUtils.failApiRequest(test, err);
done(err)