From 6363b894df21e9bb15880a640a36549a1bc1edf5 Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Mon, 5 Feb 2024 00:56:58 -0500 Subject: [PATCH] Add a test for 403 error --- src/test/java/org/takes/facets/auth/TkSecureTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/takes/facets/auth/TkSecureTest.java b/src/test/java/org/takes/facets/auth/TkSecureTest.java index ae9a7d70d..d24ca0d84 100644 --- a/src/test/java/org/takes/facets/auth/TkSecureTest.java +++ b/src/test/java/org/takes/facets/auth/TkSecureTest.java @@ -23,6 +23,7 @@ */ package org.takes.facets.auth; +import java.net.HttpURLConnection; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.api.Assertions; @@ -43,10 +44,14 @@ final class TkSecureTest { @Test void failsOnAnonymous() { final Take secure = new TkSecure(request -> new RsEmpty()); - Assertions.assertThrows( + final RsForward exception = Assertions.assertThrows( RsForward.class, () -> secure.act(new RqFake()) ); + Assertions.assertEquals( + exception.code(), + HttpURLConnection.HTTP_UNAUTHORIZED + ); } @Test