use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class LinkImplTest method absolute_URI_for_default_insecure_link.
@Test
public void absolute_URI_for_default_insecure_link() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, false, INSECURE_BASE_URL);
train_encodeURL(response, INSECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.INSECURE, response, null, baseURLSource);
assertEquals(link.toAbsoluteURI(), ENCODED);
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class LinkImplTest method force_insecure_URI_from_secure_link.
@Test
public void force_insecure_URI_from_secure_link() {
Response response = mockResponse();
BaseURLSource baseURLSource = mockBaseURLSource();
train_getBaseURL(baseURLSource, false, INSECURE_BASE_URL);
train_encodeURL(response, INSECURE_BASE_URL + BASE_PATH, ENCODED);
replay();
Link link = new LinkImpl(BASE_PATH, false, LinkSecurity.SECURE, response, null, baseURLSource);
assertEquals(link.toAbsoluteURI(false), ENCODED);
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class BaseURLSourceImplTest method getBaseURLWithContributedNonStandardSecurePort.
@Test
public void getBaseURLWithContributedNonStandardSecurePort() {
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 80, 8443);
assertEquals(baseURLSource.getBaseURL(true), "https://localhost:8443");
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class BaseURLSourceImplTest method secure_url_without_configured_hostports.
@Test
public void secure_url_without_configured_hostports() {
expect(request.isSecure()).andReturn(false).once();
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "localhost", 0, 0);
// In other words, in the absense of any other configuration, it assumes that you have SSL on port 443
// and there's no need for that in the URL, since that's what the browser is going to do.
assertEquals(baseURLSource.getBaseURL(true), "https://localhost");
verify();
}
use of org.apache.tapestry5.http.services.BaseURLSource in project tapestry-5 by apache.
the class BaseURLSourceImplTest method server_name_from_request_object.
@Test
public void server_name_from_request_object() {
expect(request.getServerName()).andReturn("localhost").once();
expect(request.getServerPort()).andReturn(80).once();
expect(request.isSecure()).andReturn(false);
replay();
BaseURLSource baseURLSource = new BaseURLSourceImpl(request, "", 0, 0);
assertEquals(baseURLSource.getBaseURL(false), "http://localhost");
verify();
}
Aggregations