extract keycloak configuration file name
This commit is contained in:
1 parent
44f56e1d74
commit
9755d79879
4 files changed
+85
-28
No files matched your search
+56
@@ -0,0 +1,56 @@
|
||||
package org.keycloak.adapters.springsecurity;
|
||||
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class AdapterDeploymentContextBeanTest {
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
private AdapterDeploymentContextBean adapterDeploymentContextBean;
|
||||
|
||||
@Test
|
||||
public void should_create_deployment_and_deployment_context() throws Exception {
|
||||
|
||||
//given:
|
||||
adapterDeploymentContextBean = new AdapterDeploymentContextBean(getCorrectResource());
|
||||
|
||||
//when:
|
||||
adapterDeploymentContextBean.afterPropertiesSet();
|
||||
|
||||
//then
|
||||
assertNotNull(adapterDeploymentContextBean.getDeployment());
|
||||
assertNotNull(adapterDeploymentContextBean.getDeploymentContext());
|
||||
}
|
||||
|
||||
private Resource getCorrectResource() {
|
||||
return new ClassPathResource("keycloak.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_throw_exception_when_configuration_file_was_not_found() throws Exception {
|
||||
|
||||
//given:
|
||||
adapterDeploymentContextBean = new AdapterDeploymentContextBean(getEmptyResource());
|
||||
|
||||
//then:
|
||||
expectedException.expect(FileNotFoundException.class);
|
||||
expectedException.expectMessage("Unable to locate Keycloak configuration file: no-file.json");
|
||||
|
||||
//when:
|
||||
adapterDeploymentContextBean.afterPropertiesSet();
|
||||
}
|
||||
|
||||
private Resource getEmptyResource() {
|
||||
return new ClassPathResource("no-file.json");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"realm": "spring-security",
|
||||
"realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCh65Gqi3BSaVe12JHlqChWm8WscICrj46MVqmRoO9FCmqbxEpCQhE1RLjW+GDyc3YdXW3xqUQ3AZxDkTmN1h6BWkhdxPLzA4EnwgWmGurhyJlUF9Id2tKns0jbC+Z7kIb2LcOiKHKL7mRb3q7EtWubNnrvunv8fx+WeXGaQoGEVQIDAQAB",
|
||||
"auth-server-url": "http://localhost:8080/auth",
|
||||
"ssl-required": "external",
|
||||
"resource": "some-resource",
|
||||
"credentials": {
|
||||
"secret": "a9c3501e-20dd-4277-8a7b-351063848446"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user