Polish URL Cleanup
This commit is contained in:
parent
d99edd154f
commit
263868f018
|
|
@ -50,7 +50,7 @@ public class DefaultDocumentLoader implements DocumentLoader {
|
|||
/**
|
||||
* JAXP attribute used to configure the schema language for validation.
|
||||
*/
|
||||
private static final String SCHEMA_LANGUAGE_ATTRIBUTE = "https://java.sun.com/xml/jaxp/properties/schemaLanguage";
|
||||
private static final String SCHEMA_LANGUAGE_ATTRIBUTE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
|
||||
|
||||
/**
|
||||
* JAXP attribute value indicating the XSD schema language.
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ import org.springframework.util.StringUtils;
|
|||
*/
|
||||
abstract class AbstractStaxXMLReader extends AbstractXMLReader {
|
||||
|
||||
private static final String NAMESPACES_FEATURE_NAME = "http://www.xml.org/sax/features/namespaces";
|
||||
private static final String NAMESPACES_FEATURE_NAME = "http://xml.org/sax/features/namespaces";
|
||||
|
||||
private static final String NAMESPACE_PREFIXES_FEATURE_NAME = "http://www.xml.org/sax/features/namespace-prefixes";
|
||||
private static final String NAMESPACE_PREFIXES_FEATURE_NAME = "http://xml.org/sax/features/namespace-prefixes";
|
||||
|
||||
private static final String IS_STANDALONE_FEATURE_NAME = "http://www.xml.org/sax/features/is-standalone";
|
||||
private static final String IS_STANDALONE_FEATURE_NAME = "http://xml.org/sax/features/is-standalone";
|
||||
|
||||
|
||||
private boolean namespacesFeature = true;
|
||||
|
|
@ -101,14 +101,14 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
|
|||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the SAX feature {@code http://www.xml.org/sax/features/namespaces} is turned on.
|
||||
* Indicates whether the SAX feature {@code http://xml.org/sax/features/namespaces} is turned on.
|
||||
*/
|
||||
protected boolean hasNamespacesFeature() {
|
||||
return this.namespacesFeature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the SAX feature {@code http://www.xml.org/sax/features/namespaces-prefixes} is turned on.
|
||||
* Indicates whether the SAX feature {@code http://xml.org/sax/features/namespaces-prefixes} is turned on.
|
||||
*/
|
||||
protected boolean hasNamespacePrefixesFeature() {
|
||||
return this.namespacePrefixesFeature;
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ abstract class AbstractXMLReader implements XMLReader {
|
|||
|
||||
/**
|
||||
* This implementation throws a {@code SAXNotRecognizedException} exception
|
||||
* for any feature outside of the "http://www.xml.org/sax/features/" namespace
|
||||
* for any feature outside of the "http://xml.org/sax/features/" namespace
|
||||
* and returns {@code false} for any feature within.
|
||||
*/
|
||||
@Override
|
||||
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if (name.startsWith("http://www.xml.org/sax/features/")) {
|
||||
if (name.startsWith("http://xml.org/sax/features/")) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
|
@ -124,12 +124,12 @@ abstract class AbstractXMLReader implements XMLReader {
|
|||
|
||||
/**
|
||||
* This implementation throws a {@code SAXNotRecognizedException} exception
|
||||
* for any feature outside of the "http://www.xml.org/sax/features/" namespace
|
||||
* for any feature outside of the "http://xml.org/sax/features/" namespace
|
||||
* and accepts a {@code false} value for any feature within.
|
||||
*/
|
||||
@Override
|
||||
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if (name.startsWith("http://www.xml.org/sax/features/")) {
|
||||
if (name.startsWith("http://xml.org/sax/features/")) {
|
||||
if (value) {
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
|
|
@ -141,12 +141,12 @@ abstract class AbstractXMLReader implements XMLReader {
|
|||
|
||||
/**
|
||||
* Throws a {@code SAXNotRecognizedException} exception when the given property does not signify a lexical
|
||||
* handler. The property name for a lexical handler is {@code http://www.xml.org/sax/properties/lexical-handler}.
|
||||
* handler. The property name for a lexical handler is {@code http://xml.org/sax/properties/lexical-handler}.
|
||||
*/
|
||||
@Override
|
||||
@Nullable
|
||||
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if ("http://www.xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
return this.lexicalHandler;
|
||||
}
|
||||
else {
|
||||
|
|
@ -156,11 +156,11 @@ abstract class AbstractXMLReader implements XMLReader {
|
|||
|
||||
/**
|
||||
* Throws a {@code SAXNotRecognizedException} exception when the given property does not signify a lexical
|
||||
* handler. The property name for a lexical handler is {@code http://www.xml.org/sax/properties/lexical-handler}.
|
||||
* handler. The property name for a lexical handler is {@code http://xml.org/sax/properties/lexical-handler}.
|
||||
*/
|
||||
@Override
|
||||
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if ("http://www.xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
this.lexicalHandler = (LexicalHandler) value;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ public abstract class AbstractStaxHandlerTestCase {
|
|||
StringWriter stringWriter = new StringWriter();
|
||||
AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter));
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", handler);
|
||||
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
|
||||
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", false);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
|
||||
|
||||
xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML)));
|
||||
|
||||
|
|
@ -103,10 +103,10 @@ public abstract class AbstractStaxHandlerTestCase {
|
|||
StringWriter stringWriter = new StringWriter();
|
||||
AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter));
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", handler);
|
||||
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
|
||||
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
|
||||
xmlReader.parse(new InputSource(new StringReader(COMPLEX_XML)));
|
||||
|
||||
|
|
@ -124,10 +124,10 @@ public abstract class AbstractStaxHandlerTestCase {
|
|||
Document result = documentBuilder.newDocument();
|
||||
AbstractStaxHandler handler = createStaxHandler(new DOMResult(result));
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", handler);
|
||||
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
|
||||
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", false);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
|
||||
|
||||
xmlReader.parse(new InputSource(new StringReader(SIMPLE_XML)));
|
||||
|
||||
|
|
@ -145,10 +145,10 @@ public abstract class AbstractStaxHandlerTestCase {
|
|||
Document result = documentBuilder.newDocument();
|
||||
AbstractStaxHandler handler = createStaxHandler(new DOMResult(result));
|
||||
xmlReader.setContentHandler(handler);
|
||||
xmlReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", handler);
|
||||
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
|
||||
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
|
||||
xmlReader.parse(new InputSource(new StringReader(SIMPLE_XML)));
|
||||
|
||||
|
|
|
|||
|
|
@ -70,14 +70,14 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
|||
|
||||
@Test
|
||||
public void contentHandlerNamespacesNoPrefixes() throws Exception {
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", false);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
|
||||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
ContentHandler contentHandler = mockContentHandler();
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", false);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
|
||||
staxXmlReader.setContentHandler(contentHandler);
|
||||
staxXmlReader.parse(new InputSource());
|
||||
|
||||
|
|
@ -86,14 +86,14 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
|||
|
||||
@Test
|
||||
public void contentHandlerNamespacesPrefixes() throws Exception {
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
ContentHandler contentHandler = mockContentHandler();
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
staxXmlReader.setContentHandler(contentHandler);
|
||||
staxXmlReader.parse(new InputSource());
|
||||
|
||||
|
|
@ -102,14 +102,14 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
|||
|
||||
@Test
|
||||
public void contentHandlerNoNamespacesPrefixes() throws Exception {
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespaces", false);
|
||||
standardReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespaces", false);
|
||||
standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
standardReader.parse(new InputSource(createTestInputStream()));
|
||||
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(createTestInputStream());
|
||||
ContentHandler contentHandler = mockContentHandler();
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespaces", false);
|
||||
staxXmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespaces", false);
|
||||
staxXmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
staxXmlReader.setContentHandler(contentHandler);
|
||||
staxXmlReader.parse(new InputSource());
|
||||
|
||||
|
|
@ -141,10 +141,10 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
|||
|
||||
LexicalHandler expectedLexicalHandler = mockLexicalHandler();
|
||||
standardReader.setContentHandler(null);
|
||||
standardReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", expectedLexicalHandler);
|
||||
standardReader.setProperty("http://xml.org/sax/properties/lexical-handler", expectedLexicalHandler);
|
||||
standardReader.parse(new InputSource(testLexicalHandlerXml.getInputStream()));
|
||||
inputFactory.setProperty("javax.xml.stream.isCoalescing", Boolean.FALSE);
|
||||
inputFactory.setProperty("https://java.sun.com/xml/stream/properties/report-cdata-event", Boolean.TRUE);
|
||||
inputFactory.setProperty("http://java.sun.com/xml/stream/properties/report-cdata-event", Boolean.TRUE);
|
||||
inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE);
|
||||
inputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", Boolean.FALSE);
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ public abstract class AbstractStaxXMLReaderTestCase {
|
|||
willAnswer(invocation -> invocation.getArguments()[0] = "element").
|
||||
given(actualLexicalHandler).startDTD(anyString(), anyString(), anyString());
|
||||
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(testLexicalHandlerXml.getInputStream());
|
||||
staxXmlReader.setProperty("http://www.xml.org/sax/properties/lexical-handler", actualLexicalHandler);
|
||||
staxXmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", actualLexicalHandler);
|
||||
staxXmlReader.parse(new InputSource());
|
||||
|
||||
// TODO: broken comparison since Mockito 2.2 upgrade
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class DomContentHandlerTests {
|
|||
|
||||
@Test
|
||||
public void contentHandlerDocumentNamespacePrefixes() throws Exception {
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
handler = new DomContentHandler(result);
|
||||
expected = documentBuilder.parse(new InputSource(new StringReader(XML_1)));
|
||||
xmlReader.setContentHandler(handler);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class SimpMessagingTemplateTests {
|
|||
MessageHeaderAccessor.getAccessor(messages.get(0), SimpMessageHeaderAccessor.class);
|
||||
|
||||
assertNotNull(headerAccessor);
|
||||
assertEquals("/user/http:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination());
|
||||
assertEquals("/user/https:%2F%2Fjoe.openid.example.org%2F/queue/foo", headerAccessor.getDestination());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -580,7 +580,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
|||
Assert.hasLength(schemaLanguage, "No schema language provided");
|
||||
Source[] schemaSources = new Source[resources.length];
|
||||
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/namespace-prefixes", true);
|
||||
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
Resource resource = resources[i];
|
||||
Assert.isTrue(resource != null && resource.exists(), () -> "Resource does not exist: " + resource);
|
||||
|
|
@ -860,8 +860,8 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi
|
|||
if (xmlReader == null) {
|
||||
xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
|
||||
}
|
||||
xmlReader.setFeature("https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
String name = "http://www.xml.org/sax/features/external-general-entities";
|
||||
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
String name = "http://xml.org/sax/features/external-general-entities";
|
||||
xmlReader.setFeature(name, isProcessExternalEntities());
|
||||
if (!isProcessExternalEntities()) {
|
||||
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
|
|
|
|||
|
|
@ -160,8 +160,8 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
|
|||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setValidating(false);
|
||||
factory.setNamespaceAware(true);
|
||||
factory.setFeature("https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
factory.setFeature("http://www.xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
factory.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
return factory;
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +191,8 @@ public abstract class AbstractMarshaller implements Marshaller, Unmarshaller {
|
|||
@SuppressWarnings("deprecation") // on JDK 9
|
||||
protected XMLReader createXmlReader() throws SAXException {
|
||||
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
|
||||
xmlReader.setFeature("https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
if (!isProcessExternalEntities()) {
|
||||
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public class MarshallingSource extends SAXSource {
|
|||
@Override
|
||||
@Nullable
|
||||
public Object getProperty(String name) throws SAXNotRecognizedException {
|
||||
if ("http://www.xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
return this.lexicalHandler;
|
||||
}
|
||||
else {
|
||||
|
|
@ -202,7 +202,7 @@ public class MarshallingSource extends SAXSource {
|
|||
|
||||
@Override
|
||||
public void setProperty(String name, Object value) throws SAXNotRecognizedException {
|
||||
if ("http://www.xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
this.lexicalHandler = (LexicalHandler) value;
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ public abstract class AbstractMarshallerTests<M extends Marshaller> {
|
|||
marshaller.marshal(flights, domResult);
|
||||
Document expected = builder.newDocument();
|
||||
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
|
||||
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
|
||||
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
|
||||
namespace.setNodeValue("http://samples.springframework.org/flight");
|
||||
flightsElement.setAttributeNode(namespace);
|
||||
expected.appendChild(flightsElement);
|
||||
|
|
@ -98,7 +98,7 @@ public abstract class AbstractMarshallerTests<M extends Marshaller> {
|
|||
Document result = (Document) domResult.getNode();
|
||||
Document expected = builder.newDocument();
|
||||
Element flightsElement = expected.createElementNS("http://samples.springframework.org/flight", "tns:flights");
|
||||
Attr namespace = expected.createAttributeNS("https://www.w3.org/2000/xmlns/", "xmlns:tns");
|
||||
Attr namespace = expected.createAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:tns");
|
||||
namespace.setNodeValue("http://samples.springframework.org/flight");
|
||||
flightsElement.setAttributeNode(namespace);
|
||||
expected.appendChild(flightsElement);
|
||||
|
|
|
|||
|
|
@ -339,8 +339,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
|
|||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
SAXSource result = sourceCaptor.getValue();
|
||||
assertEquals(true, result.getXMLReader().getFeature("https://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://www.xml.org/sax/features/external-general-entities"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
|
||||
|
||||
// 2. external-general-entities and dtd support enabled
|
||||
|
||||
|
|
@ -352,8 +352,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
|
|||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
result = sourceCaptor.getValue();
|
||||
assertEquals(false, result.getXMLReader().getFeature("https://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://www.xml.org/sax/features/external-general-entities"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
|
||||
}
|
||||
|
||||
@Test // SPR-10806
|
||||
|
|
@ -373,8 +373,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
|
|||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
SAXSource result = sourceCaptor.getValue();
|
||||
assertEquals(true, result.getXMLReader().getFeature("https://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://www.xml.org/sax/features/external-general-entities"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
|
||||
|
||||
// 2. external-general-entities and dtd support enabled
|
||||
|
||||
|
|
@ -386,8 +386,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
|
|||
verify(unmarshaller).unmarshal(sourceCaptor.capture());
|
||||
|
||||
result = sourceCaptor.getValue();
|
||||
assertEquals(false, result.getXMLReader().getFeature("https://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://www.xml.org/sax/features/external-general-entities"));
|
||||
assertEquals(false, result.getXMLReader().getFeature("http://apache.org/xml/features/disallow-doctype-decl"));
|
||||
assertEquals(true, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ public class Jaxb2UnmarshallerTests extends AbstractUnmarshallerTests<Jaxb2Marsh
|
|||
given(mimeContainer.getAttachment("<99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws>")).willReturn(dataHandler);
|
||||
given(mimeContainer.getAttachment("696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png")).willReturn(dataHandler);
|
||||
String content = "<binaryObject xmlns='http://springframework.org/spring-ws'>" + "<bytes>" +
|
||||
"<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" +
|
||||
"<xop:Include href='cid:6b76528d-7a9c-4def-8e13-095ab89e9bb7@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
|
||||
"</bytes>" + "<dataHandler>" +
|
||||
"<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='https://www.w3.org/2004/08/xop/include'/>" +
|
||||
"<xop:Include href='cid:99bd1592-0521-41a2-9688-a8bfb40192fb@http://springframework.org/spring-ws' xmlns:xop='http://www.w3.org/2004/08/xop/include'/>" +
|
||||
"</dataHandler>" +
|
||||
"<swaDataHandler>696cfb9a-4d2d-402f-bb5c-59fa69e7f0b3@spring-ws.png</swaDataHandler>" +
|
||||
"</binaryObject>";
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ public class HtmlUnitRequestBuilderTests {
|
|||
|
||||
@Test
|
||||
public void buildRequestContextPathUsesNoFirstSegmentWithDefault() throws MalformedURLException {
|
||||
webRequest.setUrl(new URL("https://example.com/"));
|
||||
webRequest.setUrl(new URL("http://example.com/"));
|
||||
String contextPath = requestBuilder.buildRequest(servletContext).getContextPath();
|
||||
|
||||
assertThat(contextPath, equalTo(""));
|
||||
|
|
@ -618,7 +618,7 @@ public class HtmlUnitRequestBuilderTests {
|
|||
|
||||
@Test
|
||||
public void buildRequestRemotePort80WithDefault() throws Exception {
|
||||
webRequest.setUrl(new URL("https://example.com/"));
|
||||
webRequest.setUrl(new URL("http://example.com/"));
|
||||
|
||||
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
|
||||
|
||||
|
|
@ -650,7 +650,7 @@ public class HtmlUnitRequestBuilderTests {
|
|||
@Test
|
||||
public void buildRequestUrl() {
|
||||
String uri = requestBuilder.buildRequest(servletContext).getRequestURL().toString();
|
||||
assertThat(uri, equalTo("https://example.com/test/this/here"));
|
||||
assertThat(uri, equalTo("http://example.com/test/this/here"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ import org.springframework.util.StringUtils;
|
|||
* <?xml version="1.0" encoding="UTF-8"?>
|
||||
* <connector xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
* xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee https://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
|
||||
* xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
|
||||
* version="1.5">
|
||||
* <vendor-name>Spring Framework</vendor-name>
|
||||
* <eis-type>Spring Connector</eis-type>
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ public class Jaxb2RootElementHttpMessageConverter extends AbstractJaxb2HttpMessa
|
|||
InputSource inputSource = new InputSource(streamSource.getInputStream());
|
||||
try {
|
||||
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
|
||||
xmlReader.setFeature("https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
String featureName = "http://www.xml.org/sax/features/external-general-entities";
|
||||
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
String featureName = "http://xml.org/sax/features/external-general-entities";
|
||||
xmlReader.setFeature(featureName, isProcessExternalEntities());
|
||||
if (!isProcessExternalEntities()) {
|
||||
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
|
|
|
|||
|
|
@ -169,9 +169,9 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
|
|||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
documentBuilderFactory.setNamespaceAware(true);
|
||||
documentBuilderFactory.setFeature(
|
||||
"https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
"http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
documentBuilderFactory.setFeature(
|
||||
"http://www.xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
"http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
if (!isProcessExternalEntities()) {
|
||||
documentBuilder.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
|
|
@ -200,8 +200,8 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
|
|||
private SAXSource readSAXSource(InputStream body, HttpInputMessage inputMessage) throws IOException {
|
||||
try {
|
||||
XMLReader xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
|
||||
xmlReader.setFeature("https://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
xmlReader.setFeature("http://www.xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !isSupportDtd());
|
||||
xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", isProcessExternalEntities());
|
||||
if (!isProcessExternalEntities()) {
|
||||
xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class ServletServerHttpRequestTests {
|
|||
@Test
|
||||
public void getUriForSimplePath() throws URISyntaxException {
|
||||
URI uri = new URI("https://example.com/path");
|
||||
mockRequest.setScheme(uri.getScheme());
|
||||
mockRequest.setServerName(uri.getHost());
|
||||
mockRequest.setServerPort(uri.getPort());
|
||||
mockRequest.setRequestURI(uri.getPath());
|
||||
|
|
@ -70,6 +71,7 @@ public class ServletServerHttpRequestTests {
|
|||
@Test
|
||||
public void getUriWithQueryString() throws URISyntaxException {
|
||||
URI uri = new URI("https://example.com/path?query");
|
||||
mockRequest.setScheme(uri.getScheme());
|
||||
mockRequest.setServerName(uri.getHost());
|
||||
mockRequest.setServerPort(uri.getPort());
|
||||
mockRequest.setRequestURI(uri.getPath());
|
||||
|
|
@ -82,7 +84,7 @@ public class ServletServerHttpRequestTests {
|
|||
mockRequest.setServerName("example.com");
|
||||
mockRequest.setRequestURI("/path");
|
||||
mockRequest.setQueryString("query=foo");
|
||||
assertEquals(new URI("https://example.com/path?query=foo"), request.getURI());
|
||||
assertEquals(new URI("http://example.com/path?query=foo"), request.getURI());
|
||||
}
|
||||
|
||||
@Test // SPR-16414
|
||||
|
|
@ -90,7 +92,7 @@ public class ServletServerHttpRequestTests {
|
|||
mockRequest.setServerName("example.com");
|
||||
mockRequest.setRequestURI("/path");
|
||||
mockRequest.setQueryString("query=foo%%x");
|
||||
assertEquals(new URI("https://example.com/path"), request.getURI());
|
||||
assertEquals(new URI("http://example.com/path"), request.getURI());
|
||||
}
|
||||
|
||||
@Test // SPR-13876
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public class ServerHttpRequestTests {
|
|||
request = createHttpRequest("/").mutate().method(HttpMethod.DELETE).build();
|
||||
assertEquals(HttpMethod.DELETE, request.getMethod());
|
||||
|
||||
String baseUri = "https://www.aaa.org/articles/";
|
||||
String baseUri = "https://aaa.org:8080/a";
|
||||
|
||||
request = createHttpRequest(baseUri).mutate().uri(URI.create("https://bbb.org:9090/b")).build();
|
||||
assertEquals("https://bbb.org:9090/b", request.getURI().toString());
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class JaxWsSupportTests {
|
|||
GenericBeanDefinition clientDef = new GenericBeanDefinition();
|
||||
clientDef.setBeanClass(JaxWsPortProxyFactoryBean.class);
|
||||
clientDef.getPropertyValues().add("wsdlDocumentUrl", "http://localhost:9999/OrderService?wsdl");
|
||||
clientDef.getPropertyValues().add("namespaceUri", "https://jaxws.remoting.springframework.org/");
|
||||
clientDef.getPropertyValues().add("namespaceUri", "http://jaxws.remoting.springframework.org/");
|
||||
clientDef.getPropertyValues().add("username", "juergen");
|
||||
clientDef.getPropertyValues().add("password", "hoeller");
|
||||
clientDef.getPropertyValues().add("serviceName", "OrderService");
|
||||
|
|
@ -83,7 +83,7 @@ public class JaxWsSupportTests {
|
|||
GenericBeanDefinition serviceFactoryDef = new GenericBeanDefinition();
|
||||
serviceFactoryDef.setBeanClass(LocalJaxWsServiceFactoryBean.class);
|
||||
serviceFactoryDef.getPropertyValues().add("wsdlDocumentUrl", "http://localhost:9999/OrderService?wsdl");
|
||||
serviceFactoryDef.getPropertyValues().add("namespaceUri", "https://jaxws.remoting.springframework.org/");
|
||||
serviceFactoryDef.getPropertyValues().add("namespaceUri", "http://jaxws.remoting.springframework.org/");
|
||||
serviceFactoryDef.getPropertyValues().add("serviceName", "OrderService");
|
||||
ac.registerBeanDefinition("orderService", serviceFactoryDef);
|
||||
|
||||
|
|
@ -152,12 +152,12 @@ public class JaxWsSupportTests {
|
|||
}
|
||||
|
||||
|
||||
@WebServiceClient(targetNamespace = "https://jaxws.remoting.springframework.org/", name="OrderService")
|
||||
@WebServiceClient(targetNamespace = "http://jaxws.remoting.springframework.org/", name="OrderService")
|
||||
public static class OrderServiceService extends Service {
|
||||
|
||||
public OrderServiceService() throws MalformedURLException {
|
||||
super(new URL("http://localhost:9999/OrderService?wsdl"),
|
||||
new QName("https://jaxws.remoting.springframework.org/", "OrderService"));
|
||||
new QName("http://jaxws.remoting.springframework.org/", "OrderService"));
|
||||
}
|
||||
|
||||
public OrderServiceService(URL wsdlDocumentLocation, QName serviceName) {
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ public class RestTemplateTests {
|
|||
public void ioExceptionWithEmptyQueryString() throws Exception {
|
||||
|
||||
// https://example.com/resource?
|
||||
URI uri = new URI("http", "example.com", "/resource", "", null);
|
||||
URI uri = new URI("https", "example.com", "/resource", "", null);
|
||||
|
||||
given(converter.canRead(String.class, null)).willReturn(true);
|
||||
given(converter.getSupportedMediaTypes()).willReturn(Collections.singletonList(parseMediaType("foo/bar")));
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class CorsUtilsTests {
|
|||
@Test // SPR-16362
|
||||
public void isSameOriginWithDifferentSchemes() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest
|
||||
.get("https://mydomain1.com")
|
||||
.get("http://mydomain1.com")
|
||||
.header(HttpHeaders.ORIGIN, "https://mydomain1.com")
|
||||
.build();
|
||||
assertFalse(CorsUtils.isSameOrigin(request));
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class RequestPartServletServerHttpRequestTests {
|
|||
ServerHttpRequest request = new RequestPartServletServerHttpRequest(this.mockRequest, "part");
|
||||
|
||||
URI uri = new URI("https://example.com/path?query");
|
||||
this.mockRequest.setScheme(uri.getScheme());
|
||||
this.mockRequest.setServerName(uri.getHost());
|
||||
this.mockRequest.setServerPort(uri.getPort());
|
||||
this.mockRequest.setRequestURI(uri.getPath());
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
|
@ -48,14 +48,14 @@ public class DefaultUriBuilderFactoryTests {
|
|||
|
||||
@Test
|
||||
public void baseUri() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1?id=123");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://foo.com/v1?id=123");
|
||||
URI uri = factory.uriString("/bar").port(8080).build();
|
||||
assertEquals("https://foo.com:8080/v1/bar?id=123", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void baseUriWithFullOverride() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1?id=123");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://foo.com/v1?id=123");
|
||||
URI uri = factory.uriString("https://example.com/1/2").build();
|
||||
assertEquals("Use of host should case baseUri to be completely ignored",
|
||||
"https://example.com/1/2", uri.toString());
|
||||
|
|
@ -63,22 +63,22 @@ public class DefaultUriBuilderFactoryTests {
|
|||
|
||||
@Test
|
||||
public void baseUriWithPathOverride() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://www.foo.com/v1");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://foo.com/v1");
|
||||
URI uri = factory.builder().replacePath("/baz").build();
|
||||
assertEquals("http://www.foo.com/baz", uri.toString());
|
||||
assertEquals("https://foo.com/baz", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultUriVars() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://{host}/v1");
|
||||
factory.setDefaultUriVariables(singletonMap("host", "foo.com"));
|
||||
URI uri = factory.uriString("/{id}").build(singletonMap("id", "123"));
|
||||
assertEquals("http://www.foo.com/v1/123", uri.toString());
|
||||
assertEquals("https://foo.com/v1/123", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultUriVarsWithOverride() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://{host}/v1");
|
||||
factory.setDefaultUriVariables(singletonMap("host", "spring.io"));
|
||||
URI uri = factory.uriString("/bar").build(singletonMap("host", "docs.spring.io"));
|
||||
assertEquals("https://docs.spring.io/v1/bar", uri.toString());
|
||||
|
|
@ -86,10 +86,10 @@ public class DefaultUriBuilderFactoryTests {
|
|||
|
||||
@Test
|
||||
public void defaultUriVarsWithEmptyVarArg() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("http://{host}/v1");
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory("https://{host}/v1");
|
||||
factory.setDefaultUriVariables(singletonMap("host", "foo.com"));
|
||||
URI uri = factory.uriString("/bar").build();
|
||||
assertEquals("Expected delegation to build(Map) method", "http://www.foo.com/v1/bar", uri.toString());
|
||||
assertEquals("Expected delegation to build(Map) method", "https://foo.com/v1/bar", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -138,7 +138,7 @@ public class DefaultUriBuilderFactoryTests {
|
|||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
|
||||
factory.setEncodingMode(EncodingMode.VALUES_ONLY);
|
||||
factory.setDefaultUriVariables(singletonMap("host", "www.example.com"));
|
||||
UriBuilder uriBuilder = factory.uriString("http://{host}/user/{userId}/dashboard");
|
||||
UriBuilder uriBuilder = factory.uriString("https://{host}/user/{userId}/dashboard");
|
||||
|
||||
assertEquals("https://www.example.com/user/john%3Bdoe/dashboard",
|
||||
uriBuilder.build(singletonMap("userId", "john;doe")).toString());
|
||||
|
|
@ -176,8 +176,8 @@ public class DefaultUriBuilderFactoryTests {
|
|||
@Test // SPR-15201
|
||||
public void pathWithTrailingSlash() {
|
||||
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory();
|
||||
URI uri = factory.expand("http://localhost:8080/spring/");
|
||||
assertEquals("http://localhost:8080/spring/", uri.toString());
|
||||
URI uri = factory.expand("https://localhost:8080/spring/");
|
||||
assertEquals("https://localhost:8080/spring/", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ public class DefaultUriTemplateHandlerTests {
|
|||
Map<String, Object> vars = new HashMap<>(1);
|
||||
vars.put("userId", "john;doe");
|
||||
|
||||
String template = "http://{host}/user/{userId}/dashboard";
|
||||
String template = "https://{host}/user/{userId}/dashboard";
|
||||
URI actual = this.handler.expand(template, vars);
|
||||
|
||||
assertEquals("https://www.example.com/user/john%3Bdoe/dashboard", actual.toString());
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public class UriComponentsBuilderTests {
|
|||
@Test
|
||||
public void plain() throws URISyntaxException {
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
|
||||
UriComponents result = builder.scheme("http").host("example.com")
|
||||
UriComponents result = builder.scheme("https").host("example.com")
|
||||
.path("foo").queryParam("bar").fragment("baz")
|
||||
.build();
|
||||
assertEquals("http", result.getScheme());
|
||||
assertEquals("https", result.getScheme());
|
||||
assertEquals("example.com", result.getHost());
|
||||
assertEquals("foo", result.getPath());
|
||||
assertEquals("bar", result.getQuery());
|
||||
|
|
@ -68,18 +68,18 @@ public class UriComponentsBuilderTests {
|
|||
@Test
|
||||
public void multipleFromSameBuilder() throws URISyntaxException {
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.newInstance()
|
||||
.scheme("http").host("example.com").pathSegment("foo");
|
||||
.scheme("https").host("example.com").pathSegment("foo");
|
||||
UriComponents result1 = builder.build();
|
||||
builder = builder.pathSegment("foo2").queryParam("bar").fragment("baz");
|
||||
UriComponents result2 = builder.build();
|
||||
|
||||
assertEquals("http", result1.getScheme());
|
||||
assertEquals("https", result1.getScheme());
|
||||
assertEquals("example.com", result1.getHost());
|
||||
assertEquals("/foo", result1.getPath());
|
||||
URI expected = new URI("https://example.com/foo");
|
||||
assertEquals("Invalid result URI", expected, result1.toUri());
|
||||
|
||||
assertEquals("http", result2.getScheme());
|
||||
assertEquals("https", result2.getScheme());
|
||||
assertEquals("example.com", result2.getHost());
|
||||
assertEquals("/foo/foo2", result2.getPath());
|
||||
assertEquals("bar", result2.getQuery());
|
||||
|
|
@ -111,7 +111,7 @@ public class UriComponentsBuilderTests {
|
|||
public void fromHierarchicalUri() throws URISyntaxException {
|
||||
URI uri = new URI("https://example.com/foo?bar#baz");
|
||||
UriComponents result = UriComponentsBuilder.fromUri(uri).build();
|
||||
assertEquals("http", result.getScheme());
|
||||
assertEquals("https", result.getScheme());
|
||||
assertEquals("example.com", result.getHost());
|
||||
assertEquals("/foo", result.getPath());
|
||||
assertEquals("bar", result.getQuery());
|
||||
|
|
@ -144,7 +144,7 @@ public class UriComponentsBuilderTests {
|
|||
@Test
|
||||
public void fromUriString() {
|
||||
UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt").build();
|
||||
assertEquals("http", result.getScheme());
|
||||
assertEquals("https", result.getScheme());
|
||||
assertNull(result.getUserInfo());
|
||||
assertEquals("www.ietf.org", result.getHost());
|
||||
assertEquals(-1, result.getPort());
|
||||
|
|
@ -156,7 +156,7 @@ public class UriComponentsBuilderTests {
|
|||
String url = "https://arjen:foobar@java.sun.com:80" +
|
||||
"/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)";
|
||||
result = UriComponentsBuilder.fromUriString(url).build();
|
||||
assertEquals("http", result.getScheme());
|
||||
assertEquals("https", result.getScheme());
|
||||
assertEquals("arjen:foobar", result.getUserInfo());
|
||||
assertEquals("java.sun.com", result.getHost());
|
||||
assertEquals(80, result.getPort());
|
||||
|
|
@ -279,7 +279,7 @@ public class UriComponentsBuilderTests {
|
|||
@Test // SPR-14761
|
||||
public void fromHttpRequestWithForwardedIPv4Host() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setScheme("http");
|
||||
request.setScheme("https");
|
||||
request.setServerName("localhost");
|
||||
request.setServerPort(-1);
|
||||
request.setRequestURI("/mvc-showcase");
|
||||
|
|
@ -288,7 +288,7 @@ public class UriComponentsBuilderTests {
|
|||
HttpRequest httpRequest = new ServletServerHttpRequest(request);
|
||||
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
|
||||
|
||||
assertEquals("/admin/", result.toString());
|
||||
assertEquals("https://192.168.0.1/mvc-showcase", result.toString());
|
||||
}
|
||||
|
||||
@Test // SPR-14761
|
||||
|
|
@ -339,7 +339,7 @@ public class UriComponentsBuilderTests {
|
|||
@Test
|
||||
public void fromHttpRequestWithForwardedHost() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.setScheme("http");
|
||||
request.setScheme("https");
|
||||
request.setServerName("localhost");
|
||||
request.setServerPort(-1);
|
||||
request.setRequestURI("/mvc-showcase");
|
||||
|
|
@ -492,7 +492,7 @@ public class UriComponentsBuilderTests {
|
|||
HttpRequest httpRequest = new ServletServerHttpRequest(request);
|
||||
UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build();
|
||||
|
||||
assertEquals("https://a.example.org/mvc-showcase", result.toString());
|
||||
assertEquals("http://a.example.org/mvc-showcase", result.toString());
|
||||
}
|
||||
|
||||
@Test // SPR-12816
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class UriComponentsTests {
|
|||
@Test // gh-22447
|
||||
public void expandWithFragmentOrder() {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromUriString("http://{host}/{path}#{fragment}").build()
|
||||
.fromUriString("https://{host}/{path}#{fragment}").build()
|
||||
.expand("example.com", "foo", "bar");
|
||||
|
||||
assertEquals("https://example.com/foo#bar", uriComponents.toUriString());
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public class UriUtilsTests {
|
|||
@Test
|
||||
public void encode() {
|
||||
assertEquals("Invalid encoded result", "foo", UriUtils.encode("foo", CHARSET));
|
||||
assertEquals("Invalid encoded result", "http%3A%2F%2Fexample.com%2Ffoo%20bar",
|
||||
assertEquals("Invalid encoded result", "https%3A%2F%2Fexample.com%2Ffoo%20bar",
|
||||
UriUtils.encode("https://example.com/foo bar", CHARSET));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,41 +92,41 @@ public class WebUtilsTests {
|
|||
@Test
|
||||
public void isValidOrigin() {
|
||||
List<String> allowed = Collections.emptyList();
|
||||
assertTrue(checkValidOrigin("mydomain1.com", -1, "https://mydomain1.com", allowed));
|
||||
assertFalse(checkValidOrigin("mydomain1.com", -1, "/QTifZ/", allowed));
|
||||
assertTrue(checkValidOrigin("mydomain1.com", -1, "http://mydomain1.com", allowed));
|
||||
assertFalse(checkValidOrigin("mydomain1.com", -1, "http://mydomain2.com", allowed));
|
||||
|
||||
allowed = Collections.singletonList("*");
|
||||
assertTrue(checkValidOrigin("mydomain1.com", -1, "/QTifZ/", allowed));
|
||||
assertTrue(checkValidOrigin("mydomain1.com", -1, "http://mydomain2.com", allowed));
|
||||
|
||||
allowed = Collections.singletonList("https://mydomain1.com");
|
||||
assertTrue(checkValidOrigin("mydomain2.com", -1, "https://mydomain1.com", allowed));
|
||||
allowed = Collections.singletonList("http://mydomain1.com");
|
||||
assertTrue(checkValidOrigin("mydomain2.com", -1, "http://mydomain1.com", allowed));
|
||||
assertFalse(checkValidOrigin("mydomain2.com", -1, "http://mydomain3.com", allowed));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSameOrigin() {
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80"));
|
||||
assertTrue(checkSameOrigin("https", "mydomain1.com", 443, "https://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("https", "mydomain1.com", 443, "https://mydomain1.com:443"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", 123, "https://mydomain1.com:123"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", 123, "http://mydomain1.com:123"));
|
||||
assertTrue(checkSameOrigin("ws", "mydomain1.com", -1, "ws://mydomain1.com"));
|
||||
assertTrue(checkSameOrigin("wss", "mydomain1.com", 443, "wss://mydomain1.com"));
|
||||
|
||||
assertFalse(checkSameOrigin("http", "mydomain1.com", -1, "/QTifZ/"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain2.com"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain1.com", -1, "invalid-origin"));
|
||||
assertFalse(checkSameOrigin("https", "mydomain1.com", -1, "https://mydomain1.com"));
|
||||
assertFalse(checkSameOrigin("https", "mydomain1.com", -1, "http://mydomain1.com"));
|
||||
|
||||
// Handling of invalid origins as described in SPR-13478
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "https://www.mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://www.mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "https://www.mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com/"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80/"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com/path"));
|
||||
assertTrue(checkSameOrigin("http", "mydomain1.com", -1, "http://mydomain1.com:80/path"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com/"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com:80/"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com/path"));
|
||||
assertFalse(checkSameOrigin("http", "mydomain2.com", -1, "http://mydomain1.com:80/path"));
|
||||
|
||||
// Handling of IPv6 hosts as described in SPR-13525
|
||||
assertTrue(checkSameOrigin("http", "[::1]", -1, "http://[::1]"));
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ public class AppCacheManifestTransformerTests {
|
|||
containsString("/static/js/bar-bd508c62235b832d960298ca6c0b7645.js"));
|
||||
|
||||
assertThat("should not rewrite external resources", content, containsString("//example.org/style.css"));
|
||||
assertThat("should not rewrite external resources", content, containsString("https://example.org/image.png"));
|
||||
assertThat("should not rewrite external resources", content, containsString("http://example.org/image.png"));
|
||||
|
||||
// Not the same hash as Spring MVC
|
||||
// Hash is computed from links, and not from the linked content
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ NETWORK:
|
|||
|
||||
CACHE:
|
||||
js/bar.js
|
||||
https://example.org/image.png
|
||||
http://example.org/image.png
|
||||
|
||||
FALLBACK:
|
||||
/main /static.html
|
||||
|
|
@ -141,6 +141,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
|
||||
@Test
|
||||
public void usesForwardedHostAsHostIfHeaderIsSet() throws Exception {
|
||||
this.request.setScheme("https");
|
||||
this.request.addHeader("X-Forwarded-Host", "somethingDifferent");
|
||||
adaptRequestFromForwardedHeaders();
|
||||
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
|
||||
|
|
@ -150,6 +151,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
|
||||
@Test
|
||||
public void usesForwardedHostAndPortFromHeader() throws Exception {
|
||||
this.request.setScheme("https");
|
||||
request.addHeader("X-Forwarded-Host", "foobar:8088");
|
||||
adaptRequestFromForwardedHeaders();
|
||||
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
|
||||
|
|
@ -159,6 +161,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
|
||||
@Test
|
||||
public void usesFirstHostOfXForwardedHost() throws Exception {
|
||||
this.request.setScheme("https");
|
||||
this.request.addHeader("X-Forwarded-Host", "barfoo:8888, localhost:8088");
|
||||
adaptRequestFromForwardedHeaders();
|
||||
UriComponents uriComponents = fromController(PersonControllerImpl.class).build();
|
||||
|
|
@ -420,6 +423,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
|
||||
initWebApplicationContext(PathPrefixWebConfig.class);
|
||||
|
||||
this.request.setScheme("https");
|
||||
this.request.setServerName("example.org");
|
||||
this.request.setServerPort(9999);
|
||||
this.request.setContextPath("/base");
|
||||
|
|
@ -433,6 +437,7 @@ public class MvcUriComponentsBuilderTests {
|
|||
|
||||
initWebApplicationContext(PathPrefixWebConfig.class);
|
||||
|
||||
this.request.setScheme("https");
|
||||
this.request.setServerName("example.org");
|
||||
this.request.setServerPort(9999);
|
||||
this.request.setContextPath("/base");
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public class AppCacheManifestTransformerTests {
|
|||
containsString("/static/js/bar-bd508c62235b832d960298ca6c0b7645.js"));
|
||||
|
||||
assertThat("should not rewrite external resources", content, containsString("//example.org/style.css"));
|
||||
assertThat("should not rewrite external resources", content, containsString("https://example.org/image.png"));
|
||||
assertThat("should not rewrite external resources", content, containsString("http://example.org/image.png"));
|
||||
|
||||
assertThat("should generate fingerprint", content,
|
||||
containsString("# Hash: 4bf0338bcbeb0a5b3a4ec9ed8864107d"));
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ NETWORK:
|
|||
|
||||
CACHE:
|
||||
js/bar.js
|
||||
https://example.org/image.png
|
||||
http://example.org/image.png
|
||||
|
||||
FALLBACK:
|
||||
/main /static.html
|
||||
|
|
@ -225,7 +225,7 @@ public class HandlersBeanDefinitionParserTests {
|
|||
assertThat(interceptors, contains(instanceOf(OriginHandshakeInterceptor.class)));
|
||||
assertTrue(transportService.shouldSuppressCors());
|
||||
assertTrue(transportService.getAllowedOrigins().contains("https://mydomain1.com"));
|
||||
assertTrue(transportService.getAllowedOrigins().contains("/QTifZ/"));
|
||||
assertTrue(transportService.getAllowedOrigins().contains("https://mydomain2.com"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -184,8 +184,8 @@ public class MessageBrokerBeanDefinitionParserTests {
|
|||
interceptors = defaultSockJsService.getHandshakeInterceptors();
|
||||
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class),
|
||||
instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class)));
|
||||
assertTrue(defaultSockJsService.getAllowedOrigins().contains("http://mydomain3.com"));
|
||||
assertTrue(defaultSockJsService.getAllowedOrigins().contains("http://www.mydomain4.com/"));
|
||||
assertTrue(defaultSockJsService.getAllowedOrigins().contains("https://mydomain3.com"));
|
||||
assertTrue(defaultSockJsService.getAllowedOrigins().contains("https://mydomain4.com"));
|
||||
|
||||
SimpUserRegistry userRegistry = this.appContext.getBean(SimpUserRegistry.class);
|
||||
assertNotNull(userRegistry);
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
|
|||
public void sameOriginMatchWithEmptyAllowedOrigins() throws Exception {
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(Collections.emptyList());
|
||||
assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
|
||||
|
|
@ -128,9 +128,9 @@ public class OriginHandshakeInterceptorTests extends AbstractHttpRequestTests {
|
|||
public void sameOriginMatchWithAllowedOrigins() throws Exception {
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(Arrays.asList("https://mydomain1.com"));
|
||||
OriginHandshakeInterceptor interceptor = new OriginHandshakeInterceptor(Arrays.asList("http://mydomain1.com"));
|
||||
assertTrue(interceptor.beforeHandshake(request, response, wsHandler, attributes));
|
||||
assertNotEquals(servletResponse.getStatus(), HttpStatus.FORBIDDEN.value());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
@Test // SPR-12226 and SPR-12660
|
||||
public void handleInfoGetWithOrigin() throws IOException {
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
|
||||
resetResponseAndHandleRequest("GET", "/echo/info", HttpStatus.OK);
|
||||
|
||||
assertEquals("application/json;charset=UTF-8", this.servletResponse.getContentType());
|
||||
|
|
@ -125,17 +125,17 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
assertEquals(",\"origins\":[\"*:*\"],\"cookie_needed\":true,\"websocket\":true}",
|
||||
body.substring(body.indexOf(',')));
|
||||
|
||||
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.com"));
|
||||
this.service.setAllowedOrigins(Collections.singletonList("http://mydomain1.com"));
|
||||
resetResponseAndHandleRequest("GET", "/echo/info", HttpStatus.OK);
|
||||
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "/QTifZ/", "http://mydomain3.com"));
|
||||
this.service.setAllowedOrigins(Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"));
|
||||
resetResponseAndHandleRequest("GET", "/echo/info", HttpStatus.OK);
|
||||
|
||||
this.service.setAllowedOrigins(Collections.singletonList("*"));
|
||||
resetResponseAndHandleRequest("GET", "/echo/info", HttpStatus.OK);
|
||||
|
||||
this.servletRequest.setServerName("mydomain3.com");
|
||||
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.com"));
|
||||
this.service.setAllowedOrigins(Collections.singletonList("http://mydomain1.com"));
|
||||
resetResponseAndHandleRequest("GET", "/echo/info", HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
|
|
@ -176,17 +176,17 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
@Test // SPR-12226 and SPR-12660
|
||||
public void handleInfoOptionsWithAllowedOrigin() {
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain2.com");
|
||||
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
|
||||
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
|
||||
assertNotNull(this.service.getCorsConfiguration(this.servletRequest));
|
||||
|
||||
this.service.setAllowedOrigins(Collections.singletonList("https://mydomain1.com"));
|
||||
this.service.setAllowedOrigins(Collections.singletonList("http://mydomain1.com"));
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
|
||||
assertNotNull(this.service.getCorsConfiguration(this.servletRequest));
|
||||
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "/QTifZ/", "http://mydomain3.com"));
|
||||
this.service.setAllowedOrigins(Arrays.asList("http://mydomain1.com", "http://mydomain2.com", "http://mydomain3.com"));
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
|
||||
assertNotNull(this.service.getCorsConfiguration(this.servletRequest));
|
||||
|
||||
|
|
@ -198,7 +198,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
@Test // SPR-16304
|
||||
public void handleInfoOptionsWithForbiddenOrigin() {
|
||||
this.servletRequest.setServerName("mydomain3.com");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.com");
|
||||
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
|
||||
this.servletRequest.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Last-Modified");
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN);
|
||||
|
|
@ -213,7 +213,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
|
||||
@Test // SPR-12283
|
||||
public void handleInfoOptionsWithOriginAndCorsHeadersDisabled() {
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.com");
|
||||
this.service.setAllowedOrigins(Collections.singletonList("*"));
|
||||
this.service.setSuppressCors(true);
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests {
|
|||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.FORBIDDEN);
|
||||
assertNull(this.service.getCorsConfiguration(this.servletRequest));
|
||||
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "/QTifZ/", "http://mydomain3.com"));
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "https://mydomain2.com", "http://mydomain3.com"));
|
||||
resetResponseAndHandleRequest("OPTIONS", "/echo/info", HttpStatus.NO_CONTENT);
|
||||
assertNull(this.service.getCorsConfiguration(this.servletRequest));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
public void handleTransportRequestXhrAllowedOriginsMatch() throws Exception {
|
||||
String sockJsPath = sessionUrlPrefix + "xhr";
|
||||
setRequest("POST", sockJsPrefix + sockJsPath);
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "/QTifZ/"));
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "https://mydomain2.com"));
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain1.com");
|
||||
this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler);
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
public void handleTransportRequestXhrAllowedOriginsNoMatch() throws Exception {
|
||||
String sockJsPath = sessionUrlPrefix + "xhr";
|
||||
setRequest("POST", sockJsPrefix + sockJsPath);
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "/QTifZ/"));
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com", "https://mydomain2.com"));
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "http://mydomain3.com");
|
||||
this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler);
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
String sockJsPath = sessionUrlPrefix + "xhr";
|
||||
setRequest("POST", sockJsPrefix + sockJsPath);
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com"));
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain1.com");
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler);
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
String sockJsPath = sessionUrlPrefix + "invalid";
|
||||
setRequest("POST", sockJsPrefix + sockJsPath);
|
||||
this.service.setAllowedOrigins(Arrays.asList("https://mydomain1.com"));
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.com");
|
||||
this.servletRequest.setServerName("mydomain2.com");
|
||||
this.service.handleRequest(this.request, this.response, sockJsPath, this.wsHandler);
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests {
|
|||
|
||||
resetRequestAndResponse();
|
||||
setRequest("GET", sockJsPrefix + sockJsPath);
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "/QTifZ/");
|
||||
this.servletRequest.addHeader(HttpHeaders.ORIGIN, "https://mydomain2.com");
|
||||
wsService.handleRequest(this.request, this.response, sockJsPath, this.wsHandler);
|
||||
assertEquals(403, this.servletResponse.getStatus());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue