Test: Added auto-commit documentation and test file

This commit is contained in:
2026-01-11 02:35:31 +08:00
parent a09ab4641c
commit 04ef89fd42
7 changed files with 516 additions and 170 deletions

57
register_gitea_user.py Normal file
View File

@@ -0,0 +1,57 @@
import requests
import re
def register_gitea_user():
# First get the CSRF token from the registration page
session = requests.Session()
# Get registration page
url = "https://git.mtrcompute.com/user/sign_up"
response = session.get(url)
# Extract CSRF token
csrf_token = None
match = re.search(r'csrfToken:\s*\'([^\']+)\'', response.text)
if match:
csrf_token = match.group(1)
else:
# Try another pattern
match = re.search(r'name="csrf_token"\s+value="([^"]+)"', response.text)
if match:
csrf_token = match.group(1)
if not csrf_token:
print("Could not find CSRF token")
return False
print(f"CSRF Token: {csrf_token}")
# Prepare registration data
data = {
'user_name': 'jleu3482',
'email': 'slclabs@gmail.com',
'password': 'jleu1212',
'retype': 'jleu1212',
'csrf_token': csrf_token
}
# Submit registration
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': url
}
response = session.post(url, data=data, headers=headers, allow_redirects=False)
print(f"Status Code: {response.status_code}")
print(f"Headers: {response.headers}")
if response.status_code == 302:
print("Registration successful! Redirecting...")
return True
else:
print(f"Registration failed. Response: {response.text[:500]}")
return False
if __name__ == "__main__":
register_gitea_user()