Commit Graph

39 Commits

Author SHA1 Message Date
Frédéric Péters 7a671f7e74 misc: introduce setting to disable https checks for given hostnames (#81541)
gitea/passerelle/pipeline/head This commit looks good Details
2023-09-29 07:39:26 +02:00
Valentin Deniaud 40142de8d2 misc: apply double-quote-string-fixer (#79788) 2023-08-16 10:08:30 +02:00
Benjamin Dauvergne f914b8542a utils: do not log requests errors when the resource is down (#72914)
gitea/passerelle/pipeline/head This commit looks good Details
2023-03-17 02:38:00 +01:00
Benjamin Dauvergne 45204e8501 base: show configured requests_substitutions (#74030) 2023-02-02 15:50:56 +01:00
Benjamin Dauvergne c218597faa misc: add setting to define string substitutions on HTTP responses (#73805)
settings.CONNECTORS_SETTINGS = {
         'cmis/test': {
           'requests_substitutions': [
	     {
	       'url': 'https://service.example.com/api/',
	       'search': 'http://service.example.internal/software/api/',
	       'replace': 'https://service.example.com/api/'
	     }
           ]
         }
	}

CONNECTORS_SETTINGS is a new setting to contain any setting pertaining
to a specific connector, it's a dictionnary of dictionnaries indexed by
connectors identifier constructed from the appname and the connector's
slug.

requests_substitutions is the first defined key in this dictionnary,
it's a list of dictionnaries:
* substitution is only done on the following content-types:
  text/*, application/(.*\+)?json, application/(.*\+)?xml
* default list of content-types can be changed through the
  REQUESTS_SUBSTITUTIONS_CONTENT_TYPES setting.
* scheme and netloc are strictly matched, path must be a prefix or empty
* search is a python regular expression
* url is optionnal, and restrict the substitution to URLs with the same
  prefix,
* replace is a replacement string for reb.sub()
* for json, structural replacement is implemented, if eventually
  escaping is used.
2023-01-31 16:09:02 +01:00
Valentin Deniaud 989fb52719 misc: apply pyupgrade (#61865) 2022-09-29 16:22:29 +02:00
Benjamin Dauvergne a958b8cec1 tests: add timeout to requests call (#68469) 2022-08-29 16:16:10 +02:00
Emmanuel Cazenave 0b1c440c83 misc: use legacy urls to call up to date urls (#65025) 2022-05-16 17:11:23 +02:00
Thomas NOËL 05a3a55e75 tests: remove use of pytest-httpbin (#63302) 2022-03-31 12:05:18 +02:00
Lauréline Guérin 86dc13a8cb
misc: fix possibly-unused-variable pylint error (#62099) 2022-03-25 09:03:38 +01:00
Lauréline Guérin 66938bfcc9
misc: fix expression-not-assigned pylint error (#62099) 2022-03-25 09:03:37 +01:00
Lauréline Guérin 2e59a6c4be
misc: fix useless-object-inheritance pylint error (#62099) 2022-03-25 09:03:36 +01:00
Lauréline Guérin 59182339ab
misc: fix redundant-u-string-prefix pylint error (#62099) 2022-03-25 09:03:36 +01:00
Lauréline Guérin 35512c9c2f
misc: remove unused-variable pylint error (#62099) 2022-03-25 09:03:36 +01:00
Lauréline Guérin c1074b68fc
misc: fix unused-import pylint error (#62099) 2022-03-25 09:03:35 +01:00
Lauréline Guérin dbb8416537
misc: add __init__ file to tests dir (#62099) 2022-03-25 08:24:24 +01:00
Benjamin Dauvergne 1911aee511 utils: add setting REQUESTS_MAX_RETRIES (#59783) 2021-12-20 16:35:40 +01:00
Benjamin Dauvergne 425ad9d7d6 utils: handle new requests_max_retries attribute on BaseResource (#59783) 2021-12-20 16:35:22 +01:00
Benjamin Dauvergne 185bd10081 utils: handle new requests_timeout attribute on BaseResource (#59783) 2021-12-20 16:34:16 +01:00
Benjamin Dauvergne 239aee2add utils: measure and log HTTP request's elapsed time (#59923) 2021-12-20 14:33:30 +01:00
Valentin Deniaud 7109698192 misc: log bytes as string without enclosing b"" (#57253) 2021-10-06 11:53:29 +02:00
Valentin Deniaud 3222eee85e tests: update headers returned by requests lib (#55600) 2021-07-15 11:00:42 +02:00
Nicolas Roche 06db6d8767 misc: apply isort (#52937) 2021-05-07 13:51:13 +02:00
Frédéric Péters 3d9df1e526 trivial: apply black (#49820) 2021-02-20 16:28:47 +01:00
Benjamin Dauvergne b8b864a863 misc: log HTTP response headers safely (#43201) 2020-05-25 11:38:33 +02:00
Emmanuel Cazenave 7e58546c3a test_requests: mock response content as bytes (#38781)
And make test indifferent to bytes vs str repr().
2020-01-29 10:30:46 +01:00
Emmanuel Cazenave 5c6ebaaa6a tests: use resp.text (#38923) 2020-01-14 19:20:26 +01:00
Nicolas Roche fc77a6e364 logging: add max sizes to connector log parameters (#36596) 2019-10-25 14:41:44 +02:00
Nicolas Roche f4544e64b9 logging: rename LOGGED_REQUESTS_MAX_SIZE parameter (#36596) 2019-10-25 14:41:26 +02:00
Nicolas Roche f469bc8cdc logging: add LOGGED_REQUEST_MAX_SIZE settings 2019-10-01 17:19:46 +02:00
Frédéric Péters 4ba28f811b utils: fix logging details of http errors (#30069) 2019-01-24 15:47:00 +01:00
Emmanuel Cazenave 0b4465a300 persist cookies on a connector instance (#28643) 2018-12-13 18:26:58 +01:00
Emmanuel Cazenave 58b5415b87 allow cookies usage in endpoint requests (#27654) 2018-11-06 09:51:23 +01:00
Frédéric Péters 624ab0a51f misc: remove broken FATAL error level (#25637) 2018-08-12 09:27:23 +02:00
Frédéric Péters ae619aa7b6 logs: unify request/response info in a single log message (#15683) 2018-06-19 09:26:18 +02:00
Serghei Mihai ace757d68c requests: add http hawk authenticator (#23693) 2018-05-14 19:40:01 +02:00
Thomas NOËL 940b269a51 add REQUESTS_TIMEOUT settings for utils.Request (#20838) 2018-01-02 09:40:28 +01:00
Frédéric Péters 7fc51ef806 utils: add cache support to requests wrapper (#17192) 2017-12-26 13:24:55 +01:00
Thomas NOËL cb5000d54d utils.Request: use auth, certs and proxy from resource, if available (#20789) 2017-12-19 14:48:04 +01:00