diff --git a/irrd/integration_tests/run.py b/irrd/integration_tests/run.py
index f0574301a..a2809dd3a 100644
--- a/irrd/integration_tests/run.py
+++ b/irrd/integration_tests/run.py
@@ -808,9 +808,7 @@ def _start_irrds(self):
os.mkdir(self.piddir1)
os.mkdir(self.piddir2)
- print(
- textwrap.dedent(
- f"""
+ print(textwrap.dedent(f"""
Preparing to start IRRd for integration test.
IRRd #1 running on HTTP port {self.port_http1}, whois port {self.port_whois1}
@@ -824,9 +822,7 @@ def _start_irrds(self):
Database URL: {self.database_url2}
PID file: {self.pidfile2}
Logfile: {self.logfile2}
- """
- )
- )
+ """))
with open(self.roa_source1, "w") as roa_file:
ujson.dump(
@@ -969,9 +965,7 @@ def _submit_update(self, config_path, request):
with a specific config path. Request is the raw RPSL update, possibly
signed with inline PGP.
"""
- email = (
- textwrap.dedent(
- """
+ email = textwrap.dedent("""
From submitter@example.com@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -987,11 +981,7 @@ def _submit_update(self, config_path, request):
Content-Type: text/plain; charset=utf-8
Mime-Version: 1.0
- """
- )
- .lstrip()
- .encode("utf-8")
- )
+ """).lstrip().encode("utf-8")
email += base64.b64encode(request.encode("utf-8"))
script = IRRD_ROOT_PATH + "/irrd/scripts/submit_email.py"
diff --git a/irrd/mirroring/tests/test_nrtm_generator.py b/irrd/mirroring/tests/test_nrtm_generator.py
index a65ec4eb9..8cf6fb29a 100644
--- a/irrd/mirroring/tests/test_nrtm_generator.py
+++ b/irrd/mirroring/tests/test_nrtm_generator.py
@@ -57,10 +57,7 @@ def test_generate_serial_range_v3(self, prepare_generator):
generator, mock_dh = prepare_generator
result = generator.generate("TEST", "3", 110, 190, mock_dh)
- assert (
- result
- == textwrap.dedent(
- """
+ assert result == textwrap.dedent("""
%START Version: 3 TEST 110-190
ADD 120
@@ -72,18 +69,13 @@ def test_generate_serial_range_v3(self, prepare_generator):
object 2 ๐
- %END TEST"""
- ).strip()
- )
+ %END TEST""").strip()
def test_generate_serial_range_v1(self, prepare_generator):
generator, mock_dh = prepare_generator
result = generator.generate("TEST", "1", 110, 190, mock_dh)
- assert (
- result
- == textwrap.dedent(
- """
+ assert result == textwrap.dedent("""
%START Version: 1 TEST 110-190
ADD
@@ -95,18 +87,13 @@ def test_generate_serial_range_v1(self, prepare_generator):
object 2 ๐
- %END TEST"""
- ).strip()
- )
+ %END TEST""").strip()
def test_generate_until_last(self, prepare_generator, config_override):
generator, mock_dh = prepare_generator
result = generator.generate("TEST", "3", 110, None, mock_dh)
- assert (
- result
- == textwrap.dedent(
- """
+ assert result == textwrap.dedent("""
%START Version: 3 TEST 110-200
ADD 120
@@ -118,9 +105,7 @@ def test_generate_until_last(self, prepare_generator, config_override):
object 2 ๐
- %END TEST"""
- ).strip()
- )
+ %END TEST""").strip()
def test_serial_range_start_higher_than_low(self, prepare_generator):
generator, mock_dh = prepare_generator
@@ -208,10 +193,7 @@ def test_v3_range_limit_not_set(self, prepare_generator, config_override):
result = generator.generate("TEST", "3", 110, 190, mock_dh)
- assert (
- result
- == textwrap.dedent(
- """
+ assert result == textwrap.dedent("""
%START Version: 3 TEST 110-190
ADD 120
@@ -223,9 +205,7 @@ def test_v3_range_limit_not_set(self, prepare_generator, config_override):
object 2 ๐
- %END TEST"""
- ).strip()
- )
+ %END TEST""").strip()
def test_range_limit_exceeded(self, prepare_generator, config_override):
generator, mock_dh = prepare_generator
@@ -248,10 +228,7 @@ def test_include_auth_hash(self, prepare_generator):
generator, mock_dh = prepare_generator
result = generator.generate("TEST", "3", 110, 190, mock_dh, False)
- assert (
- result
- == textwrap.dedent(
- """
+ assert result == textwrap.dedent("""
%START Version: 3 TEST 110-190
ADD 120
@@ -263,6 +240,4 @@ def test_include_auth_hash(self, prepare_generator):
object 2 ๐
- %END TEST"""
- ).strip()
- )
+ %END TEST""").strip()
diff --git a/irrd/rpki/importer.py b/irrd/rpki/importer.py
index 6a07766fb..4c287b9ca 100644
--- a/irrd/rpki/importer.py
+++ b/irrd/rpki/importer.py
@@ -237,15 +237,12 @@ def render_rpsl_text(self, last_modified=None):
remarks_fill = RPSL_ATTRIBUTE_TEXT_WIDTH * " "
remarks = get_setting("rpki.pseudo_irr_remarks").replace("\n", "\n" + remarks_fill).strip()
remarks = remarks.format(asn=self.asn, prefix=self.prefix_str)
- rpsl_object_text = (
- f"""
+ rpsl_object_text = f"""
{object_class_display}{self.prefix_str}
descr: RPKI ROA for {self.prefix_str} / AS{self.asn}
remarks: {remarks}
max-length: {self.max_length}
origin: AS{self.asn}
source: {RPKI_IRR_PSEUDO_SOURCE} # Trust Anchor: {self.trust_anchor}
-""".strip()
- + "\n"
- )
+""".strip() + "\n"
return rpsl_object_text
diff --git a/irrd/rpki/tests/test_importer.py b/irrd/rpki/tests/test_importer.py
index f5b6025a5..2ac57d391 100644
--- a/irrd/rpki/tests/test_importer.py
+++ b/irrd/rpki/tests/test_importer.py
@@ -195,10 +195,7 @@ def test_valid_process(self, monkeypatch, mock_scopefilter):
"rpki_max_length": 26,
"source": "RPKI",
}
- assert (
- roa_importer.roa_objs[0]._rpsl_object.render_rpsl_text()
- == textwrap.dedent(
- """
+ assert roa_importer.roa_objs[0]._rpsl_object.render_rpsl_text() == textwrap.dedent("""
route: 192.0.2.0/24
descr: RPKI ROA for 192.0.2.0/24 / AS64496
remarks: This AS64496 route object represents routing data retrieved
@@ -207,10 +204,7 @@ def test_valid_process(self, monkeypatch, mock_scopefilter):
max-length: 26
origin: AS64496
source: RPKI # Trust Anchor: APNIC RPKI Root
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
def test_invalid_rpki_json(self, monkeypatch, mock_scopefilter):
mock_dh = Mock(spec=DatabaseHandler)
diff --git a/irrd/rpki/tests/test_notifications.py b/irrd/rpki/tests/test_notifications.py
index a37bdbb86..6ec403f7a 100644
--- a/irrd/rpki/tests/test_notifications.py
+++ b/irrd/rpki/tests/test_notifications.py
@@ -82,10 +82,7 @@ def test_notify_regular(self, monkeypatch, config_override):
expected_recipients = {"person@xample.com", "person2@example.com", "mnt-nfy@example.com"}
assert actual_recipients == expected_recipients
assert mock_email.mock_calls[0][1][1] == "route(6) objects in TEST marked RPKI invalid"
- assert (
- mock_email.mock_calls[0][1][2]
- == textwrap.dedent(
- """
+ assert mock_email.mock_calls[0][1][2] == textwrap.dedent("""
This is to notify that 1 route(6) objects for which you are a
contact have been marked as RPKI invalid. This concerns
objects in the TEST database.
@@ -124,9 +121,7 @@ def test_notify_regular(self, monkeypatch, config_override):
mnt-by: DOESNOTEXIST-MNT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- ).strip()
- )
+ """).strip()
def test_notify_disabled(self, monkeypatch, config_override):
config_override(
diff --git a/irrd/scripts/expire_journal.py b/irrd/scripts/expire_journal.py
index 591c92a84..04cd15f49 100755
--- a/irrd/scripts/expire_journal.py
+++ b/irrd/scripts/expire_journal.py
@@ -37,17 +37,13 @@ def expire_journal(skip_confirmation: bool, expire_before: datetime, source: str
return 1
if not skip_confirmation:
- print(
- textwrap.dedent(
- f"""
+ print(textwrap.dedent(f"""
Found {affected_object_count} journal entries to delete from the journal for {source}.
This is the only record of history kept by IRRd itself.
After deletion, this can not be recovered.
To confirm deleting these entries for {source}, type 'yes':
- """
- ).strip()
- )
+ """).strip())
confirmation = input("> ")
if confirmation != "yes":
print("Deletion cancelled.")
diff --git a/irrd/scripts/irr_rpsl_submit.py b/irrd/scripts/irr_rpsl_submit.py
index c38785658..d5d454700 100755
--- a/irrd/scripts/irr_rpsl_submit.py
+++ b/irrd/scripts/irr_rpsl_submit.py
@@ -641,8 +641,7 @@ def format_as_text(response):
Format an IRRd HTTP response into a human-friendly text.
"""
summary = response["summary"]
- user_report = textwrap.dedent(
- f"""
+ user_report = textwrap.dedent(f"""
SUMMARY OF UPDATE:
Number of objects found: {summary["objects_found"]:3}
@@ -658,8 +657,7 @@ def format_as_text(response):
DETAILED EXPLANATION:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
for object_result in response["objects"]:
user_report += "---\n"
user_report += format_report_object(object_result)
@@ -776,8 +774,7 @@ def metadata(metadata_values):
except IndexError as error:
raise ValueError() from error
- description = textwrap.dedent(
- """\
+ description = textwrap.dedent("""\
Read RPSL submissions from stdin and return a response on stdout.
Errors or debug info are printed to stderr. This program accepts
the arguments for irrdv3's version of irr_rpsl_submit but ignores
@@ -804,8 +801,7 @@ def metadata(metadata_values):
16 - unexpected response
32 - an unidentified error
- """
- )
+ """)
parser = argparse.ArgumentParser(
add_help=False,
diff --git a/irrd/scripts/irrd_control.py b/irrd/scripts/irrd_control.py
index 125902012..e4b9dbf9e 100755
--- a/irrd/scripts/irrd_control.py
+++ b/irrd/scripts/irrd_control.py
@@ -62,9 +62,7 @@ def user_mfa_clear(email, session_provider: ORMSessionProvider):
+ (["TOTP"] if user.has_totp else [])
)
- click.echo(
- textwrap.dedent(
- f"""
+ click.echo(textwrap.dedent(f"""
You are about to remove multi-factor authentication for user:
{user.name} ({user.email})
@@ -76,9 +74,7 @@ def user_mfa_clear(email, session_provider: ORMSessionProvider):
It is your own responsibility to determine that the legitimate
user has lost access to their two-factor methods.
The user will be notified of this change.
- """
- )
- )
+ """))
click.confirm(f"Are you sure you want to remove two-factor authentication for {email}?", abort=True)
for webauthn in user.webauthns:
session_provider.session.delete(webauthn)
@@ -116,16 +112,12 @@ def user_change_override(email: str, enable: bool, session_provider: ORMSessionP
raise click.ClickException("User already has no override permission.")
if enable:
- click.echo(
- textwrap.dedent(
- f"""
+ click.echo(textwrap.dedent(f"""
You are about to assign override permission for user:
{user.name} ({user.email})
This will allow the user to edit any object in the database.
- """
- )
- )
+ """))
click.confirm(f"Are you sure you want to assign this permission to {email}?", abort=True)
user.override = enable
diff --git a/irrd/server/graphql/tests/test_schema_generator.py b/irrd/server/graphql/tests/test_schema_generator.py
index d430e74aa..2bcf3d648 100644
--- a/irrd/server/graphql/tests/test_schema_generator.py
+++ b/irrd/server/graphql/tests/test_schema_generator.py
@@ -7,9 +7,7 @@ def test_schema_generator():
assert generator.graphql_types["RPSLAsBlock"]["descr"] == "[String!]"
assert generator.graphql_types["RPSLAsBlock"]["techCObjs"] == "[RPSLContactUnion!]"
assert generator.graphql_types["RPSLRtrSet"]["rtr-set"] == "String"
- assert (
- generator.type_defs
- == """enum RPKIStatus {
+ assert generator.type_defs == """enum RPKIStatus {
valid
invalid
not_found
@@ -570,4 +568,3 @@ def test_schema_generator():
}
union RPSLContactUnion = RPSLPerson | RPSLRole"""
- )
diff --git a/irrd/server/http/status_generator.py b/irrd/server/http/status_generator.py
index fa2c100bf..e6acf606e 100644
--- a/irrd/server/http/status_generator.py
+++ b/irrd/server/http/status_generator.py
@@ -40,12 +40,10 @@ def _generate_header(self) -> str:
Generate the header of the report, containing basic info like version
and time until the next mirror update.
"""
- return textwrap.dedent(
- f"""
+ return textwrap.dedent(f"""
IRRD version {__version__}
Listening on {get_setting('server.whois.interface')} port {get_setting('server.whois.port')}
- """
- ).lstrip()
+ """).lstrip()
def _generate_statistics_table(self) -> str:
"""
@@ -121,8 +119,7 @@ def _generate_source_detail(self, database_handler: DatabaseHandler) -> str:
remote_information = self._generate_remote_status_info(nrtm_host, nrtm_port, source)
remote_information = textwrap.indent(remote_information, " " * 16)
- result_txt += textwrap.dedent(
- f"""
+ result_txt += textwrap.dedent(f"""
Status for {source}
-------------------
Local information:
@@ -143,8 +140,7 @@ def _generate_source_detail(self, database_handler: DatabaseHandler) -> str:
Route object preference: {route_object_preference}
Remote information:{remote_information}
- """
- )
+ """)
return result_txt
def _generate_remote_status_info(self, nrtm_host: Optional[str], nrtm_port: int, source: str) -> str:
@@ -161,32 +157,24 @@ def _generate_remote_status_info(self, nrtm_host: Optional[str], nrtm_port: int,
mirrorable, mirror_serial_oldest, mirror_serial_newest, mirror_export_serial = source_status
mirrorable_str = "Yes" if mirrorable else "No"
- return textwrap.dedent(
- f"""
+ return textwrap.dedent(f"""
NRTM host: {nrtm_host} port {nrtm_port}
Mirrorable: {mirrorable_str}
Oldest journal serial number: {mirror_serial_oldest}
Newest journal serial number: {mirror_serial_newest}
Last export at serial number: {mirror_export_serial}
- """
- )
+ """)
except ValueError:
- return textwrap.dedent(
- f"""
+ return textwrap.dedent(f"""
NRTM host: {nrtm_host} port {nrtm_port}
Remote status query unsupported or query failed
- """
- )
+ """)
except (socket.timeout, ConnectionError):
- return textwrap.dedent(
- f"""
+ return textwrap.dedent(f"""
NRTM host: {nrtm_host} port {nrtm_port}
Unable to reach remote server for status query
- """
- )
+ """)
else:
- return textwrap.dedent(
- """
+ return textwrap.dedent("""
No NRTM host configured.
- """
- )
+ """)
diff --git a/irrd/server/http/tests/test_status_generator.py b/irrd/server/http/tests/test_status_generator.py
index 49de72046..2d01f4faa 100644
--- a/irrd/server/http/tests/test_status_generator.py
+++ b/irrd/server/http/tests/test_status_generator.py
@@ -133,8 +133,7 @@ def mock_whois_query(nrtm_host, nrtm_port, source):
mock_database_handler.execute_query = lambda query, flush_rpsl_buffer=True: next(mock_query_result)
status_report = StatusGenerator().generate_status()
- expected_report = textwrap.dedent(
- f"""
+ expected_report = textwrap.dedent(f"""
IRRD version {__version__}
Listening on ::0 port {get_setting('server.whois.port')}
@@ -244,7 +243,6 @@ def mock_whois_query(nrtm_host, nrtm_port, source):
Route object preference: None
Remote information:
- No NRTM host configured.\n\n"""
- ).lstrip()
+ No NRTM host configured.\n\n""").lstrip()
assert expected_report == status_report
diff --git a/irrd/storage/alembic/versions/8b8357acd333_add_global_serial.py b/irrd/storage/alembic/versions/8b8357acd333_add_global_serial.py
index 10764bede..ad446cde0 100644
--- a/irrd/storage/alembic/versions/8b8357acd333_add_global_serial.py
+++ b/irrd/storage/alembic/versions/8b8357acd333_add_global_serial.py
@@ -21,8 +21,7 @@ def upgrade():
op.execute(CreateSequence(Sequence("rpsl_database_journal_serial_global_seq", start=1000000)))
op.add_column("rpsl_database_journal", sa.Column("serial_global", sa.BigInteger(), nullable=True))
- op.execute(
- """
+ op.execute("""
UPDATE rpsl_database_journal SET
serial_global = rpsl_database_journal_new.serial_global_new
FROM rpsl_database_journal AS rpsl_database_journal_old
@@ -36,8 +35,7 @@ def upgrade():
) ORDER BY timestamp
) AS rpsl_database_journal_new USING (pk)
WHERE rpsl_database_journal.pk = rpsl_database_journal_old.pk
- """
- )
+ """)
op.alter_column(
"rpsl_database_journal",
diff --git a/irrd/updates/email.py b/irrd/updates/email.py
index 10c61287c..d625d626d 100644
--- a/irrd/updates/email.py
+++ b/irrd/updates/email.py
@@ -42,14 +42,12 @@ def handle_email_submission(email_txt: str) -> Optional[ChangeSubmissionHandler]
f"Unable to extract message body from e-mail {msg.message_id} from {msg.message_from}"
)
subject = f"FAILED: {msg.message_subject}"
- reply_content = textwrap.dedent(
- f"""
+ reply_content = textwrap.dedent(f"""
Unfortunately, your message with ID {msg.message_id}
could not be processed, as no text/plain part could be found.
Please try to resend your message as plain text email.
- """
- )
+ """)
else:
handler = ChangeSubmissionHandler().load_text_blob(
msg.body, pgp_fingerprint=msg.pgp_fingerprint, request_meta=request_meta
@@ -72,12 +70,10 @@ def handle_email_submission(email_txt: str) -> Optional[ChangeSubmissionHandler]
exc_info=exc,
)
subject = f"ERROR: {msg.message_subject}"
- reply_content = textwrap.dedent(
- f"""
+ reply_content = textwrap.dedent(f"""
Unfortunately, your message with ID {msg.message_id}
could not be processed, due to an internal error.
- """
- )
+ """)
try:
email.send_email(msg.message_from, subject, reply_content)
diff --git a/irrd/updates/handler.py b/irrd/updates/handler.py
index 2952e53bd..bc1da6483 100644
--- a/irrd/updates/handler.py
+++ b/irrd/updates/handler.py
@@ -213,8 +213,7 @@ def submitter_report_human(self) -> str:
number_failed_modify = len([r for r in failed if r.request_type == UpdateRequestType.MODIFY])
number_failed_delete = len([r for r in failed if r.request_type == UpdateRequestType.DELETE])
- user_report = self._request_meta_str() + textwrap.dedent(
- f"""
+ user_report = self._request_meta_str() + textwrap.dedent(f"""
SUMMARY OF UPDATE:
Number of objects found: {len(self.results):3}
@@ -230,8 +229,7 @@ def submitter_report_human(self) -> str:
DETAILED EXPLANATION:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
for result in self.results:
user_report += "---\n"
user_report += result.submitter_report_human()
@@ -285,24 +283,20 @@ def send_notification_target_reports(self):
header = get_setting("email.notification_header", "").format(sources_str=sources_str)
header += "\nThis message is auto-generated.\n"
header += "The request was made with the following details:\n"
- header_saved = textwrap.dedent(
- """
+ header_saved = textwrap.dedent("""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some objects in which you are referenced have been created,
deleted or changed.
- """
- )
+ """)
- header_failed = textwrap.dedent(
- """
+ header_failed = textwrap.dedent("""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some objects in which you are referenced were requested
to be created, deleted or changed, but *failed* the
proper authorisation for any of the referenced maintainers.
- """
- )
+ """)
for recipient, reports_per_status in reports_per_recipient.items():
user_report = header + self._request_meta_str()
diff --git a/irrd/updates/tests/test_email.py b/irrd/updates/tests/test_email.py
index d69b9c893..c6346ce33 100644
--- a/irrd/updates/tests/test_email.py
+++ b/irrd/updates/tests/test_email.py
@@ -19,8 +19,7 @@ def mock_email_dh(monkeypatch):
class TestHandleEmailSubmission:
- default_email = textwrap.dedent(
- """
+ default_email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -37,8 +36,7 @@ class TestHandleEmailSubmission:
Mime-Version: 1.0
aut-num: AS12345
- """
- ).strip()
+ """).strip()
def test_valid_plain(self, mock_email_dh, tmp_gpg_dir):
mock_email, mock_dh = mock_email_dh
@@ -54,8 +52,7 @@ def test_valid_plain(self, mock_email_dh, tmp_gpg_dir):
def test_invalid_no_text_plain(self, mock_email_dh, tmp_gpg_dir):
mock_email, mock_dh = mock_email_dh
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -78,8 +75,7 @@ def test_invalid_no_text_plain(self, mock_email_dh, tmp_gpg_dir):
test 1 2 3
--Apple-Mail=_01FE5B2D-C7F3-4DDD-AB42-B92C88CFBF0F--
- """
- ).strip()
+ """).strip()
assert handle_email_submission(email) is None
assert mock_email.mock_calls[0][0] == ""
diff --git a/irrd/updates/tests/test_handler.py b/irrd/updates/tests/test_handler.py
index 98837a984..22a307d64 100644
--- a/irrd/updates/tests/test_handler.py
+++ b/irrd/updates/tests/test_handler.py
@@ -51,8 +51,7 @@ def test_parse_valid_new_objects_with_override(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
mock_dh.execute_query = lambda query: []
- rpsl_text = textwrap.dedent(
- """
+ rpsl_text = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 000 0000
@@ -85,8 +84,7 @@ def test_parse_valid_new_objects_with_override(self, prepare_mocks):
changed: changed@example.com 20190701 # comment
source: TEST
remarks: remark
- """
- )
+ """)
handler = ChangeSubmissionHandler().load_text_blob(rpsl_text)
assert handler.status() == "SUCCESS"
@@ -112,8 +110,7 @@ def test_parse_valid_new_objects_with_override(self, prepare_mocks):
assert mock_dh.mock_calls[3][0] == "commit"
assert mock_dh.mock_calls[4][0] == "close"
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 3
@@ -154,14 +151,12 @@ def test_parse_valid_new_objects_with_override(self, prepare_mocks):
INFO: Address range 80.16.151.184 - 80.016.151.191 was reformatted as 80.16.151.184 - 80.16.151.191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
- person_text = textwrap.dedent(
- """
+ person_text = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 000 0000
@@ -170,11 +165,9 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
e-mail: email@example.com
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
- mntner_text = textwrap.dedent(
- """
+ mntner_text = textwrap.dedent("""
mntner: TEST-MNT
admin-c: PERSON-TEST
upd-to: upd-to@example.com
@@ -183,8 +176,7 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
mnt-by: TEST-MNT
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
rpsl_text = person_text + "\n\n" + mntner_text
query_responses = iter(
@@ -226,8 +218,7 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
assert mock_dh.mock_calls[2][0] == "commit"
assert mock_dh.mock_calls[3][0] == "close"
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
> Message-ID: test
> From: example@example.com
@@ -254,11 +245,9 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
Modify succeeded: [mntner] TEST-MNT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
- expected_notification = textwrap.dedent(
- """
+ expected_notification = textwrap.dedent("""
This is to notify you of changes in the TEST database
or object authorisation failures.
@@ -309,8 +298,7 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- ).lstrip()
+ """).lstrip()
handler.send_notification_target_reports()
assert flatten_mock_calls(mock_email) == [
["", ("mnt-nfy@example.com", "Notification of TEST database changes", expected_notification), {}]
@@ -319,8 +307,7 @@ def test_parse_valid_new_person_existing_mntner_pgp_key(self, prepare_mocks):
def test_parse_invalid_new_objects_pgp_key_does_not_exist(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
- person_text = textwrap.dedent(
- """
+ person_text = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 000 0000
@@ -329,11 +316,9 @@ def test_parse_invalid_new_objects_pgp_key_does_not_exist(self, prepare_mocks):
e-mail: email@example.com
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
- mntner_text = textwrap.dedent(
- """
+ mntner_text = textwrap.dedent("""
mntner: TEST-MNT
admin-c: PERSON-TEST
upd-to: unread@ripe.net
@@ -341,8 +326,7 @@ def test_parse_invalid_new_objects_pgp_key_does_not_exist(self, prepare_mocks):
mnt-by: TEST-MNT
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
rpsl_text = person_text + "\n\n" + mntner_text
query_responses = iter(
@@ -382,8 +366,7 @@ def test_parse_invalid_new_objects_pgp_key_does_not_exist(self, prepare_mocks):
def test_parse_valid_delete(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
- rpsl_person = textwrap.dedent(
- """
+ rpsl_person = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 00000000
@@ -393,8 +376,7 @@ def test_parse_valid_delete(self, prepare_mocks):
notify: notify@example.com
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
query_responses = iter(
[
@@ -426,8 +408,7 @@ def test_parse_valid_delete(self, prepare_mocks):
assert mock_dh.mock_calls[1][0] == "commit"
assert mock_dh.mock_calls[2][0] == "close"
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 1
@@ -447,8 +428,7 @@ def test_parse_valid_delete(self, prepare_mocks):
Delete succeeded: [person] PERSON-TEST
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
assert handler.submitter_report_json() == {
"request_meta": {},
@@ -500,8 +480,7 @@ def test_parse_valid_delete(self, prepare_mocks):
],
}
- expected_notification = textwrap.dedent(
- """
+ expected_notification = textwrap.dedent("""
This is to notify you of changes in the TEST database
or object authorisation failures.
@@ -533,8 +512,7 @@ def test_parse_valid_delete(self, prepare_mocks):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- ).lstrip()
+ """).lstrip()
handler.send_notification_target_reports()
# Notification recipients are kept in unordered data types at times, so call order may vary.
@@ -553,8 +531,7 @@ def test_parse_invalid_cascading_failure(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
mock_dh.execute_query = lambda query: []
- rpsl_text = textwrap.dedent(
- """
+ rpsl_text = textwrap.dedent("""
mntner: TEST-MNT
admin-c: PERSON-TEST
upd-to: unread@ripe.net
@@ -587,8 +564,7 @@ def test_parse_invalid_cascading_failure(self, prepare_mocks):
e-mail: email@example.com
changed: changed@example.com 20190701 # comment
source: TEST
- """
- )
+ """)
handler = ChangeSubmissionHandler().load_text_blob(rpsl_text)
assert handler.status() == "FAILED"
@@ -621,8 +597,7 @@ def test_parse_invalid_cascading_failure(self, prepare_mocks):
["close", (), {}],
]
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 3
@@ -687,8 +662,7 @@ def test_parse_invalid_cascading_failure(self, prepare_mocks):
ERROR: Object OTHER-MNT referenced in field mnt-by not found in database TEST - must reference mntner.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
assert handler.submitter_report_json() == {
"request_meta": {},
@@ -809,9 +783,7 @@ def test_parse_invalid_single_failure_invalid_password(self, prepare_mocks):
)
mock_dh.execute_query = lambda query: next(query_results)
- rpsl_text = (
- textwrap.dedent(
- """
+ rpsl_text = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 000 0000
@@ -820,10 +792,7 @@ def test_parse_invalid_single_failure_invalid_password(self, prepare_mocks):
e-mail: email@example.com
changed: changed@example.com 20190701 # comment
source: TEST
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
submission_object = RPSLChangeSubmission.parse_obj(
{
@@ -850,8 +819,7 @@ def test_parse_invalid_single_failure_invalid_password(self, prepare_mocks):
["close", (), {}],
]
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 1
@@ -882,11 +850,9 @@ def test_parse_invalid_single_failure_invalid_password(self, prepare_mocks):
ERROR: Authorisation for person PERSON-TEST failed: must be authenticated by one of: TEST-MNT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
- expected_notification = textwrap.dedent(
- """
+ expected_notification = textwrap.dedent("""
This is to notify you of changes in the TEST database
or object authorisation failures.
@@ -918,8 +884,7 @@ def test_parse_invalid_single_failure_invalid_password(self, prepare_mocks):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- ).lstrip()
+ """).lstrip()
handler.send_notification_target_reports()
assert flatten_mock_calls(mock_email) == [
["", ("upd-to@example.net", "Notification of TEST database changes", expected_notification), {}],
@@ -941,8 +906,7 @@ def test_parse_invalid_cascading_failure_invalid_password(self, prepare_mocks):
)
mock_dh.execute_query = lambda query: next(query_results)
- rpsl_text = textwrap.dedent(
- """
+ rpsl_text = textwrap.dedent("""
person: Placeholder Person Object
address: The Netherlands
phone: +31 20 000 0000
@@ -975,8 +939,7 @@ def test_parse_invalid_cascading_failure_invalid_password(self, prepare_mocks):
changed: changed@example.com 20190701 # comment
source: TEST
remarks: remark
- """
- )
+ """)
handler = ChangeSubmissionHandler().load_text_blob(rpsl_text)
assert handler.status() == "FAILED"
@@ -1003,8 +966,7 @@ def test_parse_invalid_cascading_failure_invalid_password(self, prepare_mocks):
["close", (), {}],
]
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 3
@@ -1070,8 +1032,7 @@ def test_parse_invalid_cascading_failure_invalid_password(self, prepare_mocks):
INFO: Address range 80.16.151.184 - 80.016.151.191 was reformatted as 80.16.151.184 - 80.16.151.191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
def test_parse_invalid_object_delete_syntax(self, prepare_mocks):
mock_dq, mock_dh, mock_email = prepare_mocks
@@ -1100,8 +1061,7 @@ def test_parse_invalid_object_delete_syntax(self, prepare_mocks):
assert mock_dh.mock_calls[0][0] == "commit"
assert mock_dh.mock_calls[1][0] == "close"
- assert handler.submitter_report_human() == textwrap.dedent(
- """
+ assert handler.submitter_report_human() == textwrap.dedent("""
SUMMARY OF UPDATE:
Number of objects found: 1
@@ -1132,8 +1092,7 @@ def test_parse_invalid_object_delete_syntax(self, prepare_mocks):
ERROR: Can not delete object: no object found for this key in this database.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- """
- )
+ """)
def test_load_suspension_submission(self, prepare_mocks, monkeypatch):
mock_dq, mock_dh, mock_email = prepare_mocks
diff --git a/irrd/updates/tests/test_parser.py b/irrd/updates/tests/test_parser.py
index 11a2cf675..a7f12b0b4 100644
--- a/irrd/updates/tests/test_parser.py
+++ b/irrd/updates/tests/test_parser.py
@@ -1286,10 +1286,7 @@ def test_user_report(self, prepare_mocks):
)
mock_dh.execute_query = lambda query: next(query_results)
- assert (
- result_inetnum.notification_target_report()
- == textwrap.dedent(
- """
+ assert result_inetnum.notification_target_report() == textwrap.dedent("""
Delete succeeded for object below: [inetnum] 192.0.2.0 - 192.0.2.255:
inetnum: 192.0.2.0 - 192.0.2.255
@@ -1306,15 +1303,9 @@ def test_user_report(self, prepare_mocks):
source: TEST
remarks: remark
remarks: MD5-pw DummyValue # Filtered for security
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
- assert (
- result_as_set.notification_target_report()
- == textwrap.dedent(
- """
+ assert result_as_set.notification_target_report() == textwrap.dedent("""
Create succeeded for object below: [as-set] AS65537:AS-SETTEST:
as-set: AS65537:AS-SETTEST
@@ -1329,19 +1320,13 @@ def test_user_report(self, prepare_mocks):
changed: changed@example.com 20190701 # comment
source: TEST
remarks: remark
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
inetnum_modify = SAMPLE_INETNUM.replace("PERSON-TEST", "NEW-TEST")
result_inetnum_modify = parse_change_requests(inetnum_modify, mock_dh, AuthValidator(mock_dh), None)[
0
]
- assert (
- result_inetnum_modify.notification_target_report()
- == textwrap.dedent(
- """
+ assert result_inetnum_modify.notification_target_report() == textwrap.dedent("""
Modify succeeded for object below: [inetnum] 192.0.2.0 - 192.0.2.255:
@@ -4,11 +4,10 @@
@@ -1374,17 +1359,11 @@ def test_user_report(self, prepare_mocks):
changed: changed@example.com 20190701 # comment
source: TEST
remarks: remark
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
# Fake the result to look like an authentication failure
result_inetnum_modify.status = UpdateRequestStatus.ERROR_AUTH
- assert (
- result_inetnum_modify.notification_target_report()
- == textwrap.dedent(
- """
+ assert result_inetnum_modify.notification_target_report() == textwrap.dedent("""
Modify FAILED AUTHORISATION for object below: [inetnum] 192.0.2.0 - 192.0.2.255:
@@ -4,11 +4,10 @@
@@ -1417,10 +1396,7 @@ def test_user_report(self, prepare_mocks):
changed: changed@example.com 20190701 # comment
source: TEST
remarks: remark
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
with pytest.raises(ValueError) as ve:
result_unknown.notification_target_report()
@@ -1449,18 +1425,13 @@ def prepare_suspension_request_test(self, prepare_mocks, monkeypatch, config_ove
monkeypatch.setattr("irrd.updates.parser.reactivate_for_mntner", mock_reactivate_for_mntner)
mock_auth_validator.check_override.return_value = True
- default_request = (
- textwrap.dedent(
- """
+ default_request = textwrap.dedent("""
override: override-pw
suspension: suspend
mntner: MNT-SUSPEND
source: TEST
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
return (
mock_dh,
diff --git a/irrd/utils/tests/test_email.py b/irrd/utils/tests/test_email.py
index cbbcc15c9..5ab27cf4b 100644
--- a/irrd/utils/tests/test_email.py
+++ b/irrd/utils/tests/test_email.py
@@ -15,8 +15,7 @@ class TestEmailParser:
# their coupling easily cause security issues.
def test_parse_valid_plain_with_charset(self):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -33,8 +32,7 @@ def test_parse_valid_plain_with_charset(self):
Mime-Version: 1.0
message content
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body == "message content"
assert parser.message_id == "<1325754288.4989.6.camel@hostname>"
@@ -44,8 +42,7 @@ def test_parse_valid_plain_with_charset(self):
assert parser.pgp_fingerprint is None
def test_parse_valid_plain_without_charset(self):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -61,15 +58,13 @@ def test_parse_valid_plain_without_charset(self):
Mime-Version: 1.0
message content
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body == "message content"
assert parser.pgp_fingerprint is None
def test_parse_valid_multipart_text_plain_with_charset(self):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -100,15 +95,13 @@ def test_parse_valid_multipart_text_plain_with_charset(self):
test 1 2 3
--Apple-Mail=_01FE5B2D-C7F3-4DDD-AB42-B92C88CFBF0F--
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "test 1 2 3"
assert parser.pgp_fingerprint is None
def test_parse_valid_multipart_quoted_printable_with_charset(self):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -140,16 +133,14 @@ def test_parse_valid_multipart_quoted_printable_with_charset(self):
test 1 2 3
--Apple-Mail=_01FE5B2D-C7F3-4DDD-AB42-B92C88CFBF0F--
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "se font vite pรฉdagogues"
assert parser.pgp_fingerprint is None
def test_parse_valid_multipart_quoted_printable_without_charset(self):
# latin-1 will be assumed
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -182,16 +173,14 @@ def test_parse_valid_multipart_quoted_printable_without_charset(self):
test 1 2 3
--Apple-Mail=_01FE5B2D-C7F3-4DDD-AB42-B92C88CFBF0F--
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "se font vite pdagogues"
assert parser.pgp_fingerprint is None
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_valid_multipart_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -239,14 +228,10 @@ def test_parse_valid_multipart_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
QxtFWD7kfutDc40U0GjukbcPsfni1BH9AZZbUsm6YS7JMxoh1Rk=
=92HM
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "test 1 2 3"
- assert (
- parser._pgp_signature
- == textwrap.dedent(
- """
+ assert parser._pgp_signature == textwrap.dedent("""
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEhiYdjb69pPVGktZNqDg7p4DyOMYFAlthsw0ACgkQqDg7p4Dy
@@ -262,17 +247,14 @@ def test_parse_valid_multipart_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
k1Bt6Qyyn4qWD19aV6yClqyhJwZB2uoSKHvBmPIu31nHRYNr9SWD75dht8YODsmF
QxtFWD7kfutDc40U0GjukbcPsfni1BH9AZZbUsm6YS7JMxoh1Rk=
=92HM
- -----END PGP SIGNATURE-----"""
- ).strip()
- )
+ -----END PGP SIGNATURE-----""").strip()
assert parser.pgp_fingerprint == "86261D8DBEBDA4F54692D64DA8383BA780F238C6"
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_invalid_multipart_signed_ascii_with_additional_text_part(
self, tmp_gpg_dir, preload_gpg_key
):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -328,16 +310,14 @@ def test_parse_invalid_multipart_signed_ascii_with_additional_text_part(
additional text/plain part - not signed
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "additional text/plain part - not signed"
assert parser.pgp_fingerprint is None
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_valid_inline_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -374,16 +354,14 @@ def test_parse_valid_inline_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
4Ni0aIkkZY3cM0QR9EEHSCJgS2RVQujw/KZTeTQTLAJLtGtLbq8=
=Zn24
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "test 1 2 3"
assert parser.pgp_fingerprint == "86261D8DBEBDA4F54692D64DA8383BA780F238C6"
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_invalid_inline_signed_ascii_multiple_messages(self, tmp_gpg_dir, preload_gpg_key):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -439,15 +417,13 @@ def test_parse_invalid_inline_signed_ascii_multiple_messages(self, tmp_gpg_dir,
4Ni0aIkkZY3cM0QR9EEHSCJgS2RVQujw/KZTeTQTLAJLtGtLbq8=
=Zn24
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.pgp_fingerprint is None
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_valid_multipart_signed_unicode(self, tmp_gpg_dir, preload_gpg_key):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -496,16 +472,14 @@ def test_parse_valid_multipart_signed_unicode(self, tmp_gpg_dir, preload_gpg_key
-----END PGP SIGNATURE-----
--Apple-Mail=_18B291D9-548C-4458-8F17-B76537227FDF--
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "test ๐ฉ รฉ รฆ"
assert parser.pgp_fingerprint == "86261D8DBEBDA4F54692D64DA8383BA780F238C6"
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_parse_invalid_signature_multipart_signed_ascii_bad_signature(self, tmp_gpg_dir, preload_gpg_key):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -553,15 +527,13 @@ def test_parse_invalid_signature_multipart_signed_ascii_bad_signature(self, tmp_
QxtFWD7kfutDc40U0GjukbcPsfni1BH9AZZbUsm6YS7JMxoh1Rk=
=92HM
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert parser.body.strip() == "test 1 2 INVALID"
assert parser.pgp_fingerprint is None
def test_invalid_blank_body(self):
- email = textwrap.dedent(
- """
+ email = textwrap.dedent("""
From sasha@localhost Thu Jan 5 10:04:48 2018
Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1])
by hostname (Postfix) with ESMTPS id 740AD310597
@@ -576,8 +548,7 @@ def test_invalid_blank_body(self):
Mime-Version: 1.0 (Mac OS X Mail 10.3
To: sasha@localhost
X-Mailer: Apple Mail (2.3273)
- """
- ).strip()
+ """).strip()
parser = EmailParser(email)
assert not parser.body.strip()
assert parser.pgp_fingerprint is None
diff --git a/irrd/utils/tests/test_pgp.py b/irrd/utils/tests/test_pgp.py
index 0a0fc2586..60cee9bc3 100644
--- a/irrd/utils/tests/test_pgp.py
+++ b/irrd/utils/tests/test_pgp.py
@@ -8,21 +8,15 @@
class TestValidatePGPSignature:
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_valid_detached_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
- message = (
- textwrap.dedent(
- """
+ message = textwrap.dedent("""
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
\tcharset=us-ascii
test 1 2 3
- """
- ).strip()
- + "\n"
- )
+ """).strip() + "\n"
- signature = textwrap.dedent(
- """
+ signature = textwrap.dedent("""
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEhiYdjb69pPVGktZNqDg7p4DyOMYFAlthsw0ACgkQqDg7p4Dy
@@ -39,16 +33,14 @@ def test_valid_detached_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
QxtFWD7kfutDc40U0GjukbcPsfni1BH9AZZbUsm6YS7JMxoh1Rk=
=92HM
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
new_message, fingerprint = validate_pgp_signature(message, signature)
assert new_message is None
assert fingerprint == "86261D8DBEBDA4F54692D64DA8383BA780F238C6"
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_valid_inline_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
- message = textwrap.dedent(
- """
+ message = textwrap.dedent("""
UNSIGNED TEXT TO BE IGNORED
-----BEGIN PGP SIGNED MESSAGE-----
@@ -78,16 +70,14 @@ def test_valid_inline_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
=iWS2
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
new_message, fingerprint = validate_pgp_signature(message)
assert new_message.strip() == "test\n1\n\n2\n\n3"
assert fingerprint == "86261D8DBEBDA4F54692D64DA8383BA780F238C6"
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_invalid_inline_signed_ascii_multiple_messages(self, tmp_gpg_dir, preload_gpg_key):
- message = textwrap.dedent(
- """
+ message = textwrap.dedent("""
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
@@ -129,28 +119,21 @@ def test_invalid_inline_signed_ascii_multiple_messages(self, tmp_gpg_dir, preloa
4Ni0aIkkZY3cM0QR9EEHSCJgS2RVQujw/KZTeTQTLAJLtGtLbq8=
=Zn24
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
new_message, fingerprint = validate_pgp_signature(message)
assert new_message is None
assert fingerprint is None
@pytest.mark.usefixtures("tmp_gpg_dir")
def test_invalid_signature_detached_signed_ascii(self, tmp_gpg_dir, preload_gpg_key):
- message = (
- textwrap.dedent(
- """
+ message = textwrap.dedent("""
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
\tcharset=us-ascii
test 1 2 INVALID
- """
- ).strip()
- + "\n"
- )
- signature = textwrap.dedent(
- """
+ """).strip() + "\n"
+ signature = textwrap.dedent("""
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEhiYdjb69pPVGktZNqDg7p4DyOMYFAlthsw0ACgkQqDg7p4Dy
@@ -167,8 +150,7 @@ def test_invalid_signature_detached_signed_ascii(self, tmp_gpg_dir, preload_gpg_
QxtFWD7kfutDc40U0GjukbcPsfni1BH9AZZbUsm6YS7JMxoh1Rk=
=92HM
-----END PGP SIGNATURE-----
- """
- ).strip()
+ """).strip()
new_message, fingerprint = validate_pgp_signature(message, signature)
assert new_message is None
assert fingerprint is None
diff --git a/irrd/webui/endpoints_mntners.py b/irrd/webui/endpoints_mntners.py
index 77ef6f54d..8c6ea74cd 100644
--- a/irrd/webui/endpoints_mntners.py
+++ b/irrd/webui/endpoints_mntners.py
@@ -365,12 +365,10 @@ async def mntner_migrate_complete(request: Request, session_provider: ORMSession
form.rpsl_mntner_obj, origin=JournalEntryOrigin.unknown
)
- msg = textwrap.dedent(
- """
+ msg = textwrap.dedent("""
The maintainer has been migrated to IRRD internal authentication.
Existing authentication methods have been kept.
- """
- )
+ """)
await notify_mntner(session_provider, request.auth.user, auth_mntner, explanation=msg)
message(request, f"The mntner {auth_mntner.rpsl_mntner_pk} has been migrated.")
@@ -397,22 +395,18 @@ async def notify_mntner(session_provider, user: AuthUser, mntner: AuthMntner, ex
subject = f"Notification of {mntner.rpsl_mntner_source} database changes"
body = get_setting("email.notification_header", "").format(sources_str=mntner.rpsl_mntner_source)
- body += textwrap.dedent(
- f"""
+ body += textwrap.dedent(f"""
This message is auto-generated.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Internal authentication was changed for
mntner {mntner.rpsl_mntner_pk} in source {mntner.rpsl_mntner_source}
by user {user.name} ({user.email}).
- """
- )
+ """)
body += f"\n{explanation.strip()}\n"
- body += textwrap.dedent(
- """
+ body += textwrap.dedent("""
Note that this change is not visible in the RPSL object,
as these authentication settings are stored internally in IRRD.
- """
- )
+ """)
for recipient in recipients:
send_email(recipient, subject, body)