File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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' ,
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments