Skip to content

Commit de2df7a

Browse files
committed
Add a helper to detect if functional tests are running against cloud
1 parent 8448961 commit de2df7a

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

test/functional/page_objects/common_page.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import { delay } from 'bluebird';
2121
import expect from '@kbn/expect';
22+
import { get } from 'lodash';
2223
// @ts-ignore
2324
import fetch from 'node-fetch';
2425
import { FtrProviderContext } from '../ftr_provider_context';
@@ -409,6 +410,21 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
409410
});
410411
return response.status !== 200;
411412
}
413+
414+
async isCloud() {
415+
const baseUrl = this.getHostPort();
416+
const username = config.get('servers.kibana.username');
417+
const password = config.get('servers.kibana.password');
418+
const response = await fetch(baseUrl + '/api/stats?extended', {
419+
method: 'get',
420+
headers: {
421+
'Content-Type': 'application/json',
422+
Authorization: 'Basic ' + Buffer.from(username + ':' + password).toString('base64'),
423+
},
424+
});
425+
const data = await response.json();
426+
return get(data, 'usage.cloud.is_cloud_enabled', false);
427+
}
412428
}
413429

414430
return new CommonPage();

0 commit comments

Comments
 (0)