2022-01-23 13:52:38 +01:00
|
|
|
import pytest
|
2021-12-23 21:13:25 +01:00
|
|
|
|
2024-03-20 07:38:02 +01:00
|
|
|
from httpie.models import ELAPSED_TIME_LABEL, ELAPSED_DNS_RESOLUTION_LABEL, ELAPSED_ESTABLISH_CONN, ELAPSED_REQUEST_SEND, ELAPSED_TLS_HANDSHAKE
|
2022-01-23 13:52:38 +01:00
|
|
|
from httpie.output.formatters.colors import PIE_STYLE_NAMES
|
|
|
|
from .utils import http, MockEnvironment, COLOR
|
2021-12-23 21:13:25 +01:00
|
|
|
|
2022-01-23 13:52:38 +01:00
|
|
|
|
|
|
|
def test_meta_elapsed_time(httpbin):
|
|
|
|
r = http('--meta', httpbin + '/delay/1')
|
|
|
|
assert f'{ELAPSED_TIME_LABEL}: 1.' in r
|
2024-03-20 07:38:02 +01:00
|
|
|
assert ELAPSED_DNS_RESOLUTION_LABEL in r
|
|
|
|
assert ELAPSED_ESTABLISH_CONN in r
|
|
|
|
assert ELAPSED_REQUEST_SEND in r
|
|
|
|
|
|
|
|
|
|
|
|
def test_meta_extended_tls(remote_httpbin_secure):
|
|
|
|
r = http('--verify=no', '--meta', remote_httpbin_secure + '/get')
|
|
|
|
assert 'Connected to' in r
|
|
|
|
assert 'Connection secured using' in r
|
|
|
|
assert 'Server certificate' in r
|
|
|
|
assert 'Certificate validity' in r
|
|
|
|
assert 'Issuer' in r
|
|
|
|
assert 'Revocation status' in r
|
|
|
|
assert ELAPSED_TLS_HANDSHAKE in r
|
2022-01-23 13:52:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('style', ['auto', 'fruity', *PIE_STYLE_NAMES])
|
|
|
|
def test_meta_elapsed_time_colors(httpbin, style):
|
|
|
|
r = http('--style', style, '--meta', httpbin + '/get', env=MockEnvironment(colors=256))
|
|
|
|
assert COLOR in r
|
|
|
|
assert ELAPSED_TIME_LABEL in r
|