Separated checkForHttps cases into separate test methods.
parent
bed90b165e
commit
e74014906d
|
@ -21,10 +21,7 @@ package org.mitre.openid.connect.config;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jricher
|
* @author jricher
|
||||||
|
@ -32,8 +29,6 @@ import org.junit.rules.ExpectedException;
|
||||||
*/
|
*/
|
||||||
public class ConfigurationPropertiesBeanTest {
|
public class ConfigurationPropertiesBeanTest {
|
||||||
|
|
||||||
@Rule
|
|
||||||
public ExpectedException expectedException = ExpectedException.none();
|
|
||||||
/**
|
/**
|
||||||
* Test getters and setters for configuration object.
|
* Test getters and setters for configuration object.
|
||||||
*/
|
*/
|
||||||
|
@ -57,8 +52,9 @@ public class ConfigurationPropertiesBeanTest {
|
||||||
assertEquals(logoUrl, bean.getLogoImageUrl());
|
assertEquals(logoUrl, bean.getLogoImageUrl());
|
||||||
assertEquals(true, bean.isForceHttps());
|
assertEquals(true, bean.isForceHttps());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCheckForHttps() throws HttpsUrlRequiredException {
|
public void testCheckForHttpsIssuerHttpDefaultFlag() {
|
||||||
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
|
|
||||||
// issuer is http
|
// issuer is http
|
||||||
|
@ -69,22 +65,34 @@ public class ConfigurationPropertiesBeanTest {
|
||||||
catch (HttpsUrlRequiredException e) {
|
catch (HttpsUrlRequiredException e) {
|
||||||
fail("Unexpected HttpsUrlRequiredException for http issuer with default forceHttps, message:" + e.getError());
|
fail("Unexpected HttpsUrlRequiredException for http issuer with default forceHttps, message:" + e.getError());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckForHttpsIssuerHttpFalseFlag() {
|
||||||
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
|
// issuer is http
|
||||||
// set to false
|
// set to false
|
||||||
try {
|
try {
|
||||||
bean.setForceHttps(false);
|
bean.setForceHttps(false);
|
||||||
bean.checkForHttps();
|
bean.checkForHttps();
|
||||||
}
|
}
|
||||||
catch (HttpsUrlRequiredException e) {
|
catch (HttpsUrlRequiredException e) {
|
||||||
fail("Unexpected HttpsUrlRequiredException for http issuer with forceHttps=false, message:" + e.getError());
|
fail("Unexpected HttpsUrlRequiredException for http issuer with forceHttps=false, message:" + e.getError());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = HttpsUrlRequiredException.class)
|
||||||
|
public void testCheckForHttpsIssuerHttpTrueFlag() throws HttpsUrlRequiredException {
|
||||||
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
|
// issuer is http
|
||||||
// set to true
|
// set to true
|
||||||
|
|
||||||
bean.setForceHttps(true);
|
bean.setForceHttps(true);
|
||||||
this.expectedException.expect(HttpsUrlRequiredException.class);
|
|
||||||
bean.checkForHttps();
|
bean.checkForHttps();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckForHttpsIssuerHttpsDefaultFlag() {
|
||||||
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
// issuer is https
|
// issuer is https
|
||||||
// leave as default, which is unset/false
|
// leave as default, which is unset/false
|
||||||
try {
|
try {
|
||||||
|
@ -93,7 +101,12 @@ public class ConfigurationPropertiesBeanTest {
|
||||||
catch (HttpsUrlRequiredException e) {
|
catch (HttpsUrlRequiredException e) {
|
||||||
fail("Unexpected HttpsUrlRequiredException for https issuer with default forceHttps, message:" + e.getError());
|
fail("Unexpected HttpsUrlRequiredException for https issuer with default forceHttps, message:" + e.getError());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckForHttpsIssuerHttpsFalseFlag() {
|
||||||
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
|
// issuer is https
|
||||||
// set to false
|
// set to false
|
||||||
try {
|
try {
|
||||||
bean.setForceHttps(false);
|
bean.setForceHttps(false);
|
||||||
|
@ -102,7 +115,12 @@ public class ConfigurationPropertiesBeanTest {
|
||||||
catch (HttpsUrlRequiredException e) {
|
catch (HttpsUrlRequiredException e) {
|
||||||
fail("Unexpected HttpsUrlRequiredException for https issuer with forceHttps=false, message:" + e.getError());
|
fail("Unexpected HttpsUrlRequiredException for https issuer with forceHttps=false, message:" + e.getError());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCheckForHttpsIssuerHttpsTrueFlag() {
|
||||||
|
ConfigurationPropertiesBean bean = new ConfigurationPropertiesBean();
|
||||||
|
// issuer is https
|
||||||
// set to true
|
// set to true
|
||||||
try {
|
try {
|
||||||
bean.setForceHttps(true);
|
bean.setForceHttps(true);
|
||||||
|
|
Loading…
Reference in New Issue