Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-12-04 15:42:28 +01:00
parent b897fce416
commit 6dfb99f253
Signed by: y0rune
GPG Key ID: F204C385F57EB348
5 changed files with 21 additions and 19 deletions

View File

@ -29,19 +29,6 @@ public class App {
@EventListener(ApplicationReadyEvent.class)
public void importData() {
User filip = new User();
filip.setEmail("filizy@st.amu.edu.pl");
filip.setName("Filip");
filip.setSurname("Izydorczyk");
filip.setRole(UserRoles.STUDENT);
this.userService.save(filip);
User hub = new User();
hub.setEmail("hubwrz1@st.amu.edu.pl");
hub.setName("Hubert");
hub.setSurname("Wrzesiński");
hub.setRole(UserRoles.STUDENT);
this.userService.save(hub);
User mac = new User();
mac.setEmail("macglo2@st.amu.edu.pl");

View File

@ -8,6 +8,7 @@ import com.plannaplan.security.cas.CustomUAMCasValidator;
import com.plannaplan.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
@ -24,7 +25,8 @@ import io.swagger.annotations.ApiParam;
@Api(tags = { "Token" }, value = "Token", description = "Enpoints to get authorization.")
public class TokenController {
private final static String SERVICE_URL = "https://wmi.plannaplan.pl";
@Value("${plannaplan.frontendUrl}")
private String SERVICE_URL;
@Autowired
private UserService userService;

View File

@ -10,3 +10,5 @@ spring.main.allow-bean-definition-overriding=true
spring.jackson.default-property-inclusion = NON_NULL
server.port=1285
plannaplan.frontendUrl = http://localhost:3000

View File

@ -1,11 +1,17 @@
package com.plannaplan.security.cas;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
public class CustomUAMCasValidatorTest {
@Value("${plannaplan.frontendUrl}")
private String serviceUrl;
@Test
public void shouldValidateWithDomain() {
CustomUAMCasValidator validator = new CustomUAMCasValidator("https://wmi.plannaplan.pl", "ST-54649-5x4h09vzUpEIyAGmf1sz-cas.amu.edu.pl");
CustomUAMCasValidator validator = new CustomUAMCasValidator(serviceUrl, "ST-54649-5x4h09vzUpEIyAGmf1sz-cas.amu.edu.pl");
validator.validate();

View File

@ -4,15 +4,20 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;
public class DefaultUAMCasValidatorTest {
@Value("${plannaplan.frontendUrl}")
private String serviceUrl;
@Test
@Ignore
public void shouldValidateTicket() {
// you need to privide fresh ticket to make this test pass that's why it is
// marked as ignored
final DefaultUAMCasValidator validator = new DefaultUAMCasValidator("http://localhost:3000",
final DefaultUAMCasValidator validator = new DefaultUAMCasValidator(serviceUrl,
"ST-572267-cbgKrcJLd0tdCubeLqdW-cas.amu.edu.pl");
try {
System.out.println(validator.validate());
@ -24,7 +29,7 @@ public class DefaultUAMCasValidatorTest {
@Test
public void shouldNotValidateTicket() {
final DefaultUAMCasValidator validator = new DefaultUAMCasValidator("http://localhost:3000", "notticket");
final DefaultUAMCasValidator validator = new DefaultUAMCasValidator(serviceUrl, "notticket");
try {
assertTrue(validator.validate().getEmail().trim().equals(""));
} catch (CasValidationExcepiton e) {