lab-development-imb/web/08/labor/08_loesungen/curlTests.txt

93 lines
2.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

########################################
# AUFGABE 1 Routing (/login, /logout)
# Server vorher starten im Routing-Ordner:
# cd /workspaces/lab-development-imb/web/08/labor/08_loesungen/Routing
# go run main.go
########################################
# Login testen
curl 'http://localhost:8080/login'
# Logout testen
curl 'http://localhost:8080/logout'
########################################
# AUFGABE 2 JSON-Daten empfangen
# Server vorher starten im JSON-Ordner:
# cd "/workspaces/lab-development-imb/web/08/labor/08_loesungen/JSONEmpfangen"
# go run main.go
########################################
# 2.1 Formular-Endpunkt /registrierung
# Erfolgreicher POST mit Formulardaten (Status 200)
curl -X POST 'http://localhost:8080/registrierung' \
-d 'vorname=Max' \
-d 'nachname=Mustermann' \
-d 'email=max@example.com' \
-d 'handy=01701234567' \
-d 'kurs=Webentwicklung Basics' \
-d 'format=online' \
-d 'session=abend' \
-d 'agb=on'
# Fehlerfall provozieren (z.B. Vorname fehlt → Status 400)
curl -X POST 'http://localhost:8080/registrierung' \
-d 'nachname=Mustermann' \
-d 'email=max@example.com' \
-d 'format=online' \
-d 'session=abend' \
-d 'agb=on'
# 2.2 JSON-Endpunkt /registrierung-json
# Erfolgreicher JSON-POST (Status 200, JSON wird zurückgegeben)
curl -X POST 'http://localhost:8080/registrierung-json' \
-H 'Content-Type: application/json' \
-d '{
"vorname": "Max",
"nachname": "Mustermann",
"email": "max@example.com",
"handy": "01701234567",
"kurs": "Webentwicklung Basics",
"session": "abend",
"agb": "on",
"newsletter": "ja",
"equipment": "ja",
"format": "online"
}'
# Fehlerfall: ungültiges JSON (Status 400, "Json ungültig")
curl -X POST 'http://localhost:8080/registrierung-json' \
-H 'Content-Type: application/json' \
-d 'ich bin kein gültiges json'
########################################
# AUFGABE 3 Cookies mit UUID
# Server vorher starten im Cookies-Ordner:
# cd /workspaces/lab-development-imb/web/08/labor/08_loesungen/Cookies
# go run main.go
########################################
# 3.1 Cookie erzeugen (/create-cookie)
# Setzt Cookie "keks=<UUID>" und zeigt die UUID an.
# Gleichzeitig speichern wir das Cookie in cookies.txt
curl -i --cookie-jar cookies.txt 'http://localhost:8080/create-cookie'
# 3.2 Cookie anzeigen (/show-cookie)
# Liest Cookie "keks" aus cookies.txt und zeigt den Wert an.
curl -i --cookie cookies.txt 'http://localhost:8080/show-cookie'
# 3.3 Cookie löschen (/delete-cookie)
# Setzt MaxAge = -1 und löscht den Cookie.
curl -i --cookie cookies.txt 'http://localhost:8080/delete-cookie'
# 3.4 Optional: prüfen, dass er wirklich weg ist
curl -i --cookie cookies.txt 'http://localhost:8080/show-cookie'
# Erwartet: "Kein Cookie vorhanden"