feat: add helper scripts for infrastructure management and troubleshooting
This commit is contained in:
27
scripts/test_semaphore_callback.py
Normal file
27
scripts/test_semaphore_callback.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import urllib.request
|
||||
import ssl
|
||||
import sys
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
class NoRedirectHandler(urllib.request.HTTPRedirectHandler):
|
||||
def redirect_request(self, req, fp, code, msg, headers, newurl):
|
||||
return None
|
||||
|
||||
opener = urllib.request.build_opener(NoRedirectHandler)
|
||||
|
||||
url = "https://semaphore.snarfnet.net/api/auth/oidc/authentik/redirect/?code=samplecode&state=samplestate"
|
||||
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
try:
|
||||
resp = opener.open(req, timeout=8)
|
||||
print(f"Status: {resp.status} {resp.reason}")
|
||||
except urllib.error.HTTPError as e:
|
||||
print(f"Status: {e.code} {e.reason}")
|
||||
print(f"Location: {e.headers.get('Location')}")
|
||||
body = e.read().decode('utf-8', errors='replace')
|
||||
print("Body:", body[:200])
|
||||
|
||||
Reference in New Issue
Block a user