Investigación parcialmente completa. Varios endpoints funcionando y claves extraidas con GHIDRA.
This commit is contained in:
159
test_all_endpoints.py
Normal file
159
test_all_endpoints.py
Normal file
@@ -0,0 +1,159 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Probar todos los endpoints de circulaciones para ver cuáles funcionan
|
||||
"""
|
||||
|
||||
import requests
|
||||
from adif_auth import AdifAuthenticator
|
||||
import uuid
|
||||
|
||||
ACCESS_KEY = "and20210615"
|
||||
SECRET_KEY = "Jthjtr946RTt"
|
||||
|
||||
def test_endpoint(name, url, payload):
|
||||
"""
|
||||
Prueba un endpoint y retorna True si funciona
|
||||
"""
|
||||
auth = AdifAuthenticator(access_key=ACCESS_KEY, secret_key=SECRET_KEY)
|
||||
user_id = str(uuid.uuid4())
|
||||
|
||||
headers = auth.get_auth_headers("POST", url, payload, user_id=user_id)
|
||||
headers["User-key"] = auth.USER_KEY_CIRCULATION
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=payload, headers=headers, timeout=10)
|
||||
status = "✅" if response.status_code == 200 else "❌"
|
||||
print(f"{status} {name}: {response.status_code}")
|
||||
return response.status_code == 200
|
||||
except Exception as e:
|
||||
print(f"❌ {name}: Error - {e}")
|
||||
return False
|
||||
|
||||
|
||||
print("="*70)
|
||||
print("PRUEBA DE TODOS LOS ENDPOINTS DE CIRCULACIONES")
|
||||
print("="*70)
|
||||
print()
|
||||
|
||||
# 1. Departures
|
||||
print("1. Departures:")
|
||||
test_endpoint(
|
||||
"Departures",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpaths/departures/traffictype/",
|
||||
{
|
||||
"commercialService": "BOTH",
|
||||
"commercialStopType": "BOTH",
|
||||
"page": {"pageNumber": 0},
|
||||
"stationCode": "10200",
|
||||
"trafficType": "ALL"
|
||||
}
|
||||
)
|
||||
|
||||
# 2. Arrivals
|
||||
print("\n2. Arrivals:")
|
||||
test_endpoint(
|
||||
"Arrivals",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpaths/arrivals/traffictype/",
|
||||
{
|
||||
"commercialService": "BOTH",
|
||||
"commercialStopType": "BOTH",
|
||||
"page": {"pageNumber": 0},
|
||||
"stationCode": "10200",
|
||||
"trafficType": "ALL"
|
||||
}
|
||||
)
|
||||
|
||||
# 3. BetweenStations
|
||||
print("\n3. BetweenStations:")
|
||||
test_endpoint(
|
||||
"BetweenStations",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpaths/betweenstations/traffictype/",
|
||||
{
|
||||
"commercialService": "BOTH",
|
||||
"commercialStopType": "BOTH",
|
||||
"originStationCode": "10200",
|
||||
"destinationStationCode": "71801",
|
||||
"page": {"pageNumber": 0},
|
||||
"trafficType": "ALL"
|
||||
}
|
||||
)
|
||||
|
||||
# 4. OnePaths
|
||||
print("\n4. OnePaths:")
|
||||
test_endpoint(
|
||||
"OnePaths",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpathdetails/onepaths/",
|
||||
{
|
||||
"allControlPoints": True,
|
||||
"commercialNumber": None,
|
||||
"destinationStationCode": "71801",
|
||||
"launchingDate": 1733356800000,
|
||||
"originStationCode": "10200"
|
||||
}
|
||||
)
|
||||
|
||||
# 5. SeveralPaths
|
||||
print("\n5. SeveralPaths:")
|
||||
test_endpoint(
|
||||
"SeveralPaths",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpathdetails/severalpaths/",
|
||||
{
|
||||
"allControlPoints": True,
|
||||
"commercialNumber": None,
|
||||
"destinationStationCode": "71801",
|
||||
"launchingDate": 1733356800000,
|
||||
"originStationCode": "10200"
|
||||
}
|
||||
)
|
||||
|
||||
# 6. Compositions
|
||||
print("\n6. Compositions:")
|
||||
test_endpoint(
|
||||
"Compositions",
|
||||
"https://circulacion.api.adif.es/portroyalmanager/secure/circulationpaths/compositions/path/",
|
||||
{
|
||||
"allControlPoints": True,
|
||||
"commercialNumber": None,
|
||||
"destinationStationCode": "71801",
|
||||
"launchingDate": 1733356800000,
|
||||
"originStationCode": "10200"
|
||||
}
|
||||
)
|
||||
|
||||
print("\n" + "="*70)
|
||||
print("PRUEBA DE ENDPOINTS DE ESTACIONES")
|
||||
print("="*70)
|
||||
print()
|
||||
|
||||
# 7. OneStation
|
||||
print("7. OneStation:")
|
||||
auth = AdifAuthenticator(access_key=ACCESS_KEY, secret_key=SECRET_KEY)
|
||||
user_id = str(uuid.uuid4())
|
||||
url = "https://estaciones.api.adif.es/portroyalmanager/secure/stations/onestation/"
|
||||
payload = {
|
||||
"stationCode": "10200",
|
||||
"detailedInfo": {
|
||||
"extendedStationInfo": True,
|
||||
"stationActivities": True,
|
||||
"stationBanner": True,
|
||||
"stationCommercialServices": True,
|
||||
"stationInfo": True,
|
||||
"stationServices": True,
|
||||
"stationTransportServices": True
|
||||
}
|
||||
}
|
||||
headers = auth.get_auth_headers("POST", url, payload, user_id=user_id)
|
||||
headers["User-key"] = auth.USER_KEY_STATIONS # ← Clave diferente
|
||||
response = requests.post(url, json=payload, headers=headers, timeout=10)
|
||||
status = "✅" if response.status_code == 200 else "❌"
|
||||
print(f"{status} OneStation: {response.status_code}")
|
||||
|
||||
# 8. StationObservations
|
||||
print("\n8. StationObservations:")
|
||||
url = "https://estaciones.api.adif.es/portroyalmanager/secure/stationsobservations/"
|
||||
payload = {"stationCodes": ["10200", "71801"]}
|
||||
headers = auth.get_auth_headers("POST", url, payload, user_id=user_id)
|
||||
headers["User-key"] = auth.USER_KEY_STATIONS
|
||||
response = requests.post(url, json=payload, headers=headers, timeout=10)
|
||||
status = "✅" if response.status_code == 200 else "❌"
|
||||
print(f"{status} StationObservations: {response.status_code}")
|
||||
Reference in New Issue
Block a user