@@ -9,49 +9,45 @@ import expect from '@kbn/expect';
99export default function ( { getService } ) {
1010 const supertestNoAuth = getService ( 'supertestWithoutAuth' ) ;
1111 const supertest = getService ( 'supertest' ) ;
12+ const config = getService ( 'config' ) ;
1213
1314 describe ( '/api/stats' , ( ) => {
1415 describe ( 'operational stats and usage stats' , ( ) => {
16+ // lazy check for uuid for test runs against preexisting services
17+ function isUUID ( uuid ) {
18+ return typeof uuid === 'string' && uuid . length === 36 ;
19+ }
20+
1521 describe ( 'no auth' , ( ) => {
16- it ( 'should return 200 and stats for no extended' , async ( ) => {
22+ // depends on kibana.yml setting status.allowAnonymous
23+ // skip this test when running against a remote host, as we can't
24+ // validate the status of this setting
25+ const host = config . get ( 'servers.kibana.hostname' ) ;
26+ const ifLocalhost = host . includes ( 'localhost' ) ? it : it . skip ;
27+ ifLocalhost ( 'should return 200 and stats for no extended' , async ( ) => {
1728 const { body } = await supertestNoAuth . get ( '/api/stats' ) . expect ( 200 ) ;
18- expect ( body . kibana . uuid ) . to . eql ( '5b2de169-2785-441b-ae8c-186a1936b17d' ) ;
19- expect ( body . process . uptime_ms ) . to . be . greaterThan ( 0 ) ;
20- expect ( body . os . uptime_ms ) . to . be . greaterThan ( 0 ) ;
21- expect ( body . usage ) . to . be ( undefined ) ;
29+ expect ( isUUID ( body . kibana . uuid ) ) . to . be . ok ( ) ;
2230 } ) ;
2331
24- // FLAKY: https://github.com/elastic/kibana/issues/29254
25- it . skip ( 'should return 401 for extended' , async ( ) => {
26- await supertestNoAuth . get ( '/api/stats?extended' ) . expect ( 401 ) ; // unauthorized
32+ it ( 'should return 401 for extended' , async ( ) => {
33+ await supertestNoAuth . get ( '/api/stats?extended' ) . expect ( 401 ) ;
2734 } ) ;
2835 } ) ;
2936
3037 describe ( 'with auth' , ( ) => {
3138 it ( 'should return 200 and stats for no extended' , async ( ) => {
3239 const { body } = await supertest . get ( '/api/stats' ) . expect ( 200 ) ;
33- expect ( body . kibana . uuid ) . to . eql ( '5b2de169-2785-441b-ae8c-186a1936b17d' ) ;
34- expect ( body . process . uptime_ms ) . to . be . greaterThan ( 0 ) ;
35- expect ( body . os . uptime_ms ) . to . be . greaterThan ( 0 ) ;
40+ expect ( isUUID ( body . kibana . uuid ) ) . to . be . ok ( ) ;
3641 } ) ;
3742
3843 it ( 'should return 200 for extended' , async ( ) => {
3944 const { body } = await supertest . get ( '/api/stats?extended' ) . expect ( 200 ) ;
40- expect ( body . kibana . uuid ) . to . eql ( '5b2de169-2785-441b-ae8c-186a1936b17d' ) ;
41- expect ( body . process . uptime_ms ) . to . be . greaterThan ( 0 ) ;
42- expect ( body . os . uptime_ms ) . to . be . greaterThan ( 0 ) ;
43- expect ( body . usage . kibana . index ) . to . be ( '.kibana' ) ;
44- expect ( body . usage . kibana . dashboard . total ) . to . be ( 0 ) ;
45+ expect ( isUUID ( body . kibana . uuid ) ) . to . be . ok ( ) ;
4546 } ) ;
4647
4748 it ( 'should return 200 for extended and legacy' , async ( ) => {
4849 const { body } = await supertest . get ( '/api/stats?extended&legacy' ) . expect ( 200 ) ;
49- expect ( body . kibana . uuid ) . to . eql ( '5b2de169-2785-441b-ae8c-186a1936b17d' ) ;
50- expect ( body . process . uptime_ms ) . to . be . greaterThan ( 0 ) ;
51- expect ( body . os . uptime_ms ) . to . be . greaterThan ( 0 ) ;
52- expect ( body . usage . index ) . to . be ( '.kibana' ) ;
53- expect ( body . usage . dashboard . total ) . to . be ( 0 ) ;
54- expect ( body . usage . xpack . reporting . available ) . to . be ( true ) ;
50+ expect ( isUUID ( body . kibana . uuid ) ) . to . be . ok ( ) ;
5551 } ) ;
5652 } ) ;
5753 } ) ;
0 commit comments