Buckets:

download
raw
5.12 kB
#!/usr/bin/env python3
"""
Simple OIDC Conformance Test
Tests basic OIDC flows against Authly
"""
import json
import requests
import sys
from datetime import datetime
# Disable SSL warnings for self-signed certificates
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def test_oidc_discovery():
"""Test OIDC discovery endpoints"""
print("\n๐Ÿ” Testing OIDC Discovery...")
# Test with underscore (current implementation)
try:
response = requests.get("http://localhost:8000/.well-known/openid_configuration")
if response.status_code == 200:
print(" โš ๏ธ Works with underscore but VIOLATES SPEC")
config = response.json()
print(f" โœ“ Issuer: {config.get('issuer')}")
print(f" โœ“ Authorization endpoint: {config.get('authorization_endpoint')}")
print(f" โœ“ Token endpoint: {config.get('token_endpoint')}")
else:
print(f" โœ— Underscore endpoint failed: {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
# Test with hyphen (spec-compliant)
try:
response = requests.get("http://localhost:8000/.well-known/openid-configuration")
if response.status_code == 200:
print(" โœ… Works with hyphen (SPEC COMPLIANT)")
else:
print(f" โŒ SPEC VIOLATION: Hyphen endpoint returns {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
def test_jwks():
"""Test JWKS endpoint"""
print("\n๐Ÿ”‘ Testing JWKS Endpoint...")
try:
response = requests.get("http://localhost:8000/.well-known/jwks.json")
if response.status_code == 200:
jwks = response.json()
print(f" โœ“ JWKS available with {len(jwks.get('keys', []))} key(s)")
else:
print(f" โœ— JWKS failed: {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
def test_authorization_endpoint():
"""Test authorization endpoint"""
print("\n๐Ÿ” Testing Authorization Endpoint...")
params = {
"client_id": "test-client",
"response_type": "code",
"redirect_uri": "http://localhost:8080/callback",
"scope": "openid",
"state": "test123",
}
try:
response = requests.get("http://localhost:8000/api/v1/oauth/authorize", params=params)
# We expect either a redirect or an error
if response.status_code in [401, 403]:
print(f" โš ๏ธ Returns {response.status_code} instead of redirect")
elif response.status_code == 302:
print(" โœ“ Returns redirect as expected")
else:
print(f" ? Unexpected status: {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
def test_token_endpoint():
"""Test token endpoint error handling"""
print("\n๐ŸŽซ Testing Token Endpoint...")
# Test missing parameters
try:
response = requests.post("http://localhost:8000/api/v1/oauth/token", data={})
if response.status_code == 422:
print(" โš ๏ธ Returns 422 for invalid request (should be 400)")
elif response.status_code == 400:
print(" โœ“ Returns 400 for invalid request")
else:
print(f" ? Unexpected status: {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
# Test with invalid grant
data = {"grant_type": "authorization_code", "code": "invalid", "client_id": "test", "client_secret": "test"}
try:
response = requests.post("http://localhost:8000/api/v1/oauth/token", data=data)
print(f" โ†’ Invalid grant returns: {response.status_code}")
if response.status_code == 400:
error = response.json()
print(f" Error: {error.get('error', 'unknown')}")
except Exception as e:
print(f" โœ— Error: {e}")
def test_userinfo_endpoint():
"""Test userinfo endpoint"""
print("\n๐Ÿ‘ค Testing UserInfo Endpoint...")
try:
response = requests.get("http://localhost:8000/oidc/userinfo")
if response.status_code == 401:
print(" โœ“ Returns 401 without authentication")
else:
print(f" ? Unexpected status: {response.status_code}")
except Exception as e:
print(f" โœ— Error: {e}")
def main():
print("=" * 50)
print("OIDC Conformance Quick Test")
print("=" * 50)
print(f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
# Run tests
test_oidc_discovery()
test_jwks()
test_authorization_endpoint()
test_token_endpoint()
test_userinfo_endpoint()
print("\n" + "=" * 50)
print("โš ๏ธ Key Issues Found:")
print(" 1. Discovery endpoint uses underscore (spec violation)")
print(" 2. Token endpoint returns 422 instead of 400")
print(" 3. Authorization endpoint returns 401 instead of redirect")
print("\n๐Ÿ’ก Fix these issues to improve OIDC compliance")
print("=" * 50)
if __name__ == "__main__":
main()

Xet Storage Details

Size:
5.12 kB
ยท
Xet hash:
93b2de523f5b5f59eb54bb33ed92caeb3b7f9f71ac3fb10a21e8893f21bc0a97

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.