Skip to content

Commit d202d04

Browse files
committed
Merge branch 'master' of github.com:pryv/lib-js
2 parents 481ac9f + c6d618e commit d202d04

9 files changed

Lines changed: 2524 additions & 9147 deletions

File tree

components/pryv-monitor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pryv/monitor",
3-
"version": "2.3.6",
3+
"version": "2.3.7",
44
"description": "Extends `pryv` with event-driven notifications for changes on a Pryv.io account",
55
"keywords": [
66
"Pryv",

components/pryv-socket.io/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pryv/socket.io",
3-
"version": "2.3.6",
3+
"version": "2.3.7",
44
"description": "Extends `pryv` with Socket.IO transport",
55
"keywords": [
66
"Pryv",

components/pryv/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pryv",
3-
"version": "2.3.6",
3+
"version": "2.3.7",
44
"description": "Pryv JavaScript library",
55
"keywords": [
66
"Pryv",

components/pryv/src/Service.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ 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+
return !hostname.includes('{username}');
88+
}
89+
7190
/**
7291
* @private
7392
* @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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
/* global describe, it, before, expect, pryv, testData */
66
/* eslint-disable no-unused-expressions */
77

8+
const isNode = (typeof window === 'undefined');
9+
810
describe('Service', function () {
911
before(async function () {
1012
this.timeout(5000);
@@ -75,7 +77,19 @@ describe('Service', function () {
7577
it('login() failed on wrong username', async function () {
7678
this.timeout(5000);
7779
const pryvService = new pryv.Service(testData.serviceInfoUrl);
78-
await expect(pryvService.login('wrong-username', 'bobby', 'jslib-test')).to.be.rejectedWith('getaddrinfo ENOTFOUND wrong');
80+
// check if username is in path or domain
81+
try {
82+
await pryvService.login('wrong-username', 'bobby', 'jslib-test');
83+
} catch (error) {
84+
let errorMessage = isNode ? 'getaddrinfo ENOTFOUND wrong' : 'Request has been terminated';
85+
if (await pryvService.isDnsLess()) {
86+
errorMessage = 'Unknown user "wrong-username"';
87+
}
88+
const receivedMessage = error.message.slice(0, errorMessage.length);
89+
expect(receivedMessage).to.be.equal(errorMessage);
90+
return;
91+
}
92+
throw new Error('Should fail');
7993
});
8094
});
8195
});

0 commit comments

Comments
 (0)