Postman을 사용하여 Spring Security에서 구현한 세션 기반 로그인 및 로그아웃 기능을 테스트
요청 구성
로그인 요청 예시
POST /login HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: localhost:8080
응답 결과
HTTP 상태 코드: 200 OK
Response Body: 없음 (Spring Security 기본 설정)
Response Headers:
Set-Cookie: JSESSIONID=<세션ID> (Postman에서 자동으로 쿠키를 저장)
HTTP 상태 코드: 401 Unauthorized
Response Body: 로그인 실패 메시지
요청 구성
로그아웃 요청 예시
POST /logout HTTP/1.1
Host: localhost:8080
Cookie: JSESSIONID=<로그인 성공 시 받은 세션 ID>
응답 결과
HTTP 상태 코드: 302 Found (기본 설정에 따라 리다이렉션)
Redirect Location: /login (기본 로그아웃 성공 후 리다이렉트 경로)
HTTP 상태 코드: 403 Forbidden (로그아웃 시 인증 정보가 없는 경우)
GET /login HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Cookie: JSESSIONID=D389FD339E34A9DA00174898FF5930C6
Host: localhost:8080
...
HTTP/1.1 200
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Type: text/html;charset=UTF-8
Content-Length: 1408
Date: Mon, 09 Dec 2024 15:46:29 GMT
Keep-Alive: timeout=60
Connection: keep-alive
GET /logout HTTP/1.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7
Connection: keep-alive
Cookie: JSESSIONID=F39DF6E54346B57C53EE911B292480FA
Host: localhost:8080
...
HTTP/1.1 302
Set-Cookie: JSESSIONID=; Max-Age=0; Expires=Thu, 01 Jan 1970 00:00:10 GMT; Path=/
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Location: http://localhost:8080/home
Content-Length: 0
Date: Mon, 09 Dec 2024 15:46:29 GMT
Keep-Alive: timeout=60
Connection: keep-alive