Skip to content

Commit 1a39d8f

Browse files
committed
added support for testing against dnsLess (open source)
1 parent 0be7aeb commit 1a39d8f

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

components/pryv/src/Service.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ class Service {
6868
return this._serviceInfo;
6969
}
7070

71+
/**
72+
* Check if a service supports High Frequency Data Sets
73+
* @return true if yes
74+
*/
75+
async supportsHF () {
76+
const infos = await this.info();
77+
return (infos.features == null || infos.features.noHF !== true);
78+
}
79+
80+
/**
81+
* Check if a service has username in the hostname or in the path of the api
82+
* @return true if the service does not rely on DNS to find a host related to a username
83+
*/
84+
async isDnsLess () {
85+
const infos = await this.info();
86+
const hostname = infos.api.split('/')[2];
87+
console.log('XXXXX', hostname);
88+
return !hostname.includes('{username}');
89+
}
90+
7191
/**
7292
* @private
7393
* @param {ServiceInfo} serviceInfo

components/pryv/test/Connection.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,13 @@ describe('Connection', () => {
262262
});
263263
});
264264

265-
describe('HF events', () => {
265+
describe('HF events', async function () {
266+
before(async function () {
267+
if (!await conn.service.supportsHF()) {
268+
this.skip();
269+
}
270+
});
271+
266272
it('Add data points to HF event', async () => {
267273
const res = await conn.api([{
268274
method: 'events.create',

components/pryv/test/Service.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ describe('Service', function () {
7575
it('login() failed on wrong username', async function () {
7676
this.timeout(5000);
7777
const pryvService = new pryv.Service(testData.serviceInfoUrl);
78-
await expect(pryvService.login('wrong-username', 'bobby', 'jslib-test')).to.be.rejectedWith('getaddrinfo ENOTFOUND wrong');
78+
// check if username is in path or domain
79+
if (await pryvService.isDnsLess()) {
80+
await expect(pryvService.login('wrong-username', 'bobby', 'jslib-test')).to.be.rejectedWith('Unknown user "wrong-username"');
81+
} else {
82+
await expect(pryvService.login('wrong-username', 'bobby', 'jslib-test')).to.be.rejectedWith('getaddrinfo ENOTFOUND wrong');
83+
}
7984
});
8085
});
8186
});

0 commit comments

Comments
 (0)