new-features (#5)
* refactoring and rework: runner now has setups / tests / cleanups as lists * add nextcloud runner * add email testing prototype with imap fixture * add dependency resolution (sort env files in input so that test order is correct) Reviewed-on: local-it-infrastructure/e2e_tests#5 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
2e33f8f014
commit
d3dc0f942a
32 changed files with 573 additions and 247 deletions
0
prototyping/__init__.py
Normal file
0
prototyping/__init__.py
Normal file
47
prototyping/email_stuff.py
Normal file
47
prototyping/email_stuff.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
# %%
|
||||
import email
|
||||
import json
|
||||
from email.header import decode_header
|
||||
from imaplib import IMAP4, IMAP4_SSL
|
||||
from pathlib import Path
|
||||
|
||||
# -------------------------------- credentials ------------------------------- #
|
||||
|
||||
cred_file = Path("../credentials.json")
|
||||
with open(cred_file, "r") as f:
|
||||
CREDENTIALS = json.load(f)
|
||||
|
||||
username = CREDENTIALS["imap_user"]
|
||||
password = CREDENTIALS["imap_pass"]
|
||||
|
||||
|
||||
# ----------------------------------- imap ----------------------------------- #
|
||||
|
||||
host = "mail.local-it.org"
|
||||
imap_port = 143
|
||||
imap_ssl_port = 993
|
||||
|
||||
|
||||
with IMAP4_SSL(host=host) as imap_server:
|
||||
imap_server.login(username, password)
|
||||
imap_server.select("INBOX")
|
||||
|
||||
# Search for all emails in the folder
|
||||
status, email_ids = imap_server.search(None, "ALL")
|
||||
email_ids = email_ids[0].split()
|
||||
|
||||
# Fetch email details using the retrieved IDs
|
||||
for email_id in email_ids:
|
||||
result, data = imap_server.fetch(email_id, "(RFC822)")
|
||||
raw_email = data[0][1] # Raw content of the email
|
||||
email_message = email.message_from_bytes(raw_email)
|
||||
|
||||
# Extract the subject
|
||||
subject_encoded = email_message.get("Subject")
|
||||
decoded_subject = decode_header(subject_encoded)[0][0]
|
||||
|
||||
if isinstance(decoded_subject, bytes):
|
||||
decoded_subject = decoded_subject.decode()
|
||||
|
||||
# Print or use the subject as needed
|
||||
print("Subject:", decoded_subject)
|
||||
10
prototyping/test_urllib.py
Normal file
10
prototyping/test_urllib.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# %%
|
||||
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
|
||||
|
||||
string = "blog.dev.local-it.cloud"
|
||||
|
||||
|
||||
parsed_url = urlparse(string, scheme="https")
|
||||
print(parsed_url)
|
||||
|
||||
print(urlunparse(parsed_url))
|
||||
Loading…
Add table
Add a link
Reference in a new issue