Commit 6617a03a authored by Diego Molteni's avatar Diego Molteni
Browse files

fixed unit tests

parent 9028e977
Pipeline #46752 passed with stages
in 11 minutes and 15 seconds
......@@ -18,6 +18,7 @@ import request from 'request-promise';
import sinon from 'sinon';
import { Config } from '../../../src/cloud';
import { google } from '../../../src/cloud/providers';
import { ConfigGoogle } from '../../../src/cloud/providers/google';
import { DESCompliance } from '../../../src/dataecosystem/compliance';
import { RecordLatency } from '../../../src/metrics/metrics';
import { Cache } from '../../../src/shared';
......@@ -30,6 +31,8 @@ export class TestCompliance {
describe(Tx.testInit('dataecosystem compliance'), () => {
ConfigGoogle.DATA_PARTITION_REST_HEADER_KEY = 'data-partition-id'
beforeEach(() => {
this.sandbox = sinon.createSandbox();
this.sandbox.stub(RecordLatency.prototype, 'record').resolves();
......@@ -50,7 +53,7 @@ export class TestCompliance {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
json: { names: ['ltag'] },
url: Config.DES_SERVICE_HOST_COMPLIANCE + '/legal/v1/legaltags:validate',
......
......@@ -18,6 +18,7 @@ import request from 'request-promise';
import sinon from 'sinon';
import { Config } from '../../../src/cloud';
import { google } from '../../../src/cloud/providers';
import { ConfigGoogle } from '../../../src/cloud/providers/google';
import { DESEntitlement } from '../../../src/dataecosystem';
import { RecordLatency } from '../../../src/metrics/metrics';
import { Error } from '../../../src/shared/error';
......@@ -30,6 +31,9 @@ export class TestDESEntitlement {
describe(Tx.testInit('dataecosystem entitlements'), () => {
ConfigGoogle.ENTITLEMENT_BASE_URL_PATH = '/entitlements'
ConfigGoogle.DATA_PARTITION_REST_HEADER_KEY = 'data-partition-id'
beforeEach(() => {
this.sandbox = sinon.createSandbox();
this.sandbox.stub(RecordLatency.prototype, 'record').resolves();
......@@ -67,9 +71,9 @@ export class TestDESEntitlement {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-one',
'data-partition-id': 'tenant-one',
},
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/v2/groups',
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements' + '/groups',
};
Tx.checkTrue(requestStub.calledWith(options), done);
});
......@@ -101,13 +105,13 @@ export class TestDESEntitlement {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
json: {
email: 'user@email',
role: 'role-a',
},
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/v2/groups/' + 'group-a' + '/members',
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements' + '/groups' + '/group-a' + '/members',
};
Tx.checkTrue(requestStub.calledWith(options), done);
......@@ -139,9 +143,9 @@ export class TestDESEntitlement {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/v2/groups/' + 'group-a' + '/members/' + 'user@email',
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/groups/' + 'group-a' + '/members/' + 'user@email',
};
Tx.checkTrue(requestStub.calledWith(options), done);
......@@ -172,13 +176,13 @@ export class TestDESEntitlement {
'AppKey':'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
json: {
description: 'group desc',
name: 'group-a',
},
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/v2/groups',
url: Config.DES_SERVICE_HOST_ENTITLEMENT + '/entitlements/groups',
};
Tx.checkTrue(requestStub.calledWith(options), done);
......
......@@ -18,6 +18,7 @@ import request from 'request-promise';
import sinon from 'sinon';
import { Config } from '../../../src/cloud';
import { google } from '../../../src/cloud/providers';
import { ConfigGoogle } from '../../../src/cloud/providers/google';
import { DESStorage, DESUtils } from '../../../src/dataecosystem';
import { RecordLatency } from '../../../src/metrics/metrics';
import { Tx } from '../utils';
......@@ -28,6 +29,8 @@ export class TestStorage {
describe(Tx.testInit('dataecosystem storage service'), () => {
ConfigGoogle.DATA_PARTITION_REST_HEADER_KEY = 'data-partition-id'
beforeEach(() => {
this.sandbox = sinon.createSandbox();
this.sandbox.stub(RecordLatency.prototype, 'record').resolves();
......@@ -71,7 +74,7 @@ export class TestStorage {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
json: JSON.stringify({ seismetadata: 'data' }),
url: Config.DES_SERVICE_HOST_STORAGE + '/storage/v2/records',
......@@ -126,7 +129,7 @@ export class TestStorage {
'AppKey': 'appkey',
'Authorization': 'Bearer usertoken',
'Content-Type': 'application/json',
'slb-data-partition-id': 'tenant-a',
'data-partition-id': 'tenant-a',
},
url: Config.DES_SERVICE_HOST_STORAGE + '/storage/v2/records/uid' + ':delete',
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment