暂存提交
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
package com.baiyue.lastleg.security;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
class InternalServiceTokenGuardTest {
|
||||
@Test void acceptsOnlyConfiguredToken() {
|
||||
InternalServiceTokenGuard guard=new InternalServiceTokenGuard("secret-token");
|
||||
assertDoesNotThrow(()->guard.verify("secret-token"));
|
||||
assertEquals(401,assertThrows(ResponseStatusException.class,()->guard.verify("wrong")).getStatusCode().value());
|
||||
assertEquals(401,assertThrows(ResponseStatusException.class,()->guard.verify(null)).getStatusCode().value());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user