toBeTrue(); $_SERVER['HTTPS'] = 'off'; expect(cacti_is_https())->toBeFalse(); unset($_SERVER['HTTPS']); expect(cacti_is_https())->toBeFalse(); }); test('a forwarded proto is honoured only when proxy trust is enabled', function () { $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; // proxy trust off: a client-supplied header must NOT force https $GLOBALS['config']['proxy_headers'] = []; expect(cacti_is_https())->toBeFalse(); // proxy trust on: the forwarded proto is honoured $GLOBALS['config']['proxy_headers'] = ['REMOTE_ADDR']; expect(cacti_is_https())->toBeTrue(); }); test('X-Forwarded-SSL on is honoured under proxy trust', function () { $GLOBALS['config']['proxy_headers'] = true; $_SERVER['HTTP_X_FORWARDED_SSL'] = 'on'; expect(cacti_is_https())->toBeTrue(); }); test('get_guest_account requires the guest user to be enabled', function () use ($functions) { $start = strpos($functions, 'function get_guest_account('); expect(substr($functions, $start, 400))->toContain("enabled = 'on'"); }); test('permission where-clauses cast ids to int', function () use ($auth) { expect($auth)->not->toContain('" gl.id = $graph_id"'); expect($auth)->not->toContain('" h.id = $device_id"'); expect($auth)->toContain('(int) $graph_id'); expect($auth)->toContain('(int) $device_id'); }); test('path_dsstats_log is escaped in the shell redirect', function () use ($dsstats) { expect(substr_count($dsstats, "cacti_escapeshellarg(read_config_option('path_dsstats_log'))"))->toBe(2); });