Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum TlsUpgrade
/**
* Automatic TLS upgrade is enabled only for {@link ProxyType#INTERNET}, default.
*/
AUTOMATIC;
AUTOMATIC
}

/**
Expand Down Expand Up @@ -111,8 +111,11 @@ public ApacheHttpClient5FactoryBuilder maxConnectionsTotal( final int maxConnect
}

/**
* Sets the automatic TLS upgrade strategy. This strategy controls whether insecure connections should be
* automatically upgraded.
* Sets the {@code Upgrade} header. Only {@link ProxyType#INTERNET} has the {@code Upgrade} header by default.
* <p>
* <b>{@link TlsUpgrade#DISABLED} only works for {@link ProxyType#INTERNET}</b>
* <p>
* <b>{@link TlsUpgrade#ENABLED} only works for {@link ProxyType#ON_PREMISE}</b>
*
* @since 5.14.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,21 @@ enum TestDestination
@RequiredArgsConstructor
enum TestAssertion
{
DEFAULT(List.of("Connection", "Host", "User-Agent", "Accept-Encoding"), Map.of()),
NONE(
List.of("Connection", "Host", "User-Agent", "Accept-Encoding"),
List.of("Connection", "Upgrade"),
Map.of()),
KEEP_ALIVE(
List.of("Connection", "Host", "User-Agent", "Accept-Encoding"),
List.of("Upgrade"),
Map.of("Connection", "keep-alive")),
UPGRADE(
List.of("Connection", "Host", "User-Agent", "Accept-Encoding", "Upgrade"),
List.of(),
Map.of("Connection", "Upgrade", "Upgrade", "TLS/1.2"));

private final List<String> headersAllowed;
private final List<String> headersForbidden;
private final Map<String, String> headersRequired;
}

Expand All @@ -79,22 +88,22 @@ static class TestCase
private static final TestCase[] TEST_CASES =
{
// Forced HTTP/TLS upgrade
new TestCase(TestDestination.INTERNET, ENABLED, TestAssertion.UPGRADE),
new TestCase(TestDestination.INTERNET, ENABLED, TestAssertion.KEEP_ALIVE),
new TestCase(TestDestination.PROXY, ENABLED, TestAssertion.UPGRADE),
new TestCase(TestDestination.ON_PREMISE, ENABLED, TestAssertion.UPGRADE),
new TestCase(TestDestination.TLS_VERSION, ENABLED, TestAssertion.UPGRADE),
new TestCase(TestDestination.TLS_VERSION, ENABLED, TestAssertion.KEEP_ALIVE),

// Disabled HTTP/TLS upgrade
new TestCase(TestDestination.INTERNET, DISABLED, TestAssertion.DEFAULT),
new TestCase(TestDestination.PROXY, DISABLED, TestAssertion.DEFAULT),
new TestCase(TestDestination.ON_PREMISE, DISABLED, TestAssertion.DEFAULT),
new TestCase(TestDestination.TLS_VERSION, DISABLED, TestAssertion.DEFAULT),
new TestCase(TestDestination.INTERNET, DISABLED, TestAssertion.KEEP_ALIVE),
new TestCase(TestDestination.PROXY, DISABLED, TestAssertion.NONE),
new TestCase(TestDestination.ON_PREMISE, DISABLED, TestAssertion.NONE),
new TestCase(TestDestination.TLS_VERSION, DISABLED, TestAssertion.KEEP_ALIVE),

// Automatic HTTP/TLS upgrade
new TestCase(TestDestination.INTERNET, AUTOMATIC, TestAssertion.UPGRADE),
new TestCase(TestDestination.INTERNET, AUTOMATIC, TestAssertion.KEEP_ALIVE),
new TestCase(TestDestination.PROXY, AUTOMATIC, TestAssertion.UPGRADE),
new TestCase(TestDestination.ON_PREMISE, AUTOMATIC, TestAssertion.DEFAULT),
new TestCase(TestDestination.TLS_VERSION, AUTOMATIC, TestAssertion.DEFAULT) };
new TestCase(TestDestination.ON_PREMISE, AUTOMATIC, TestAssertion.NONE),
new TestCase(TestDestination.TLS_VERSION, AUTOMATIC, TestAssertion.KEEP_ALIVE) };

@SneakyThrows
@ParameterizedTest
Expand All @@ -108,6 +117,7 @@ void testHeader( @Nonnull final TestCase testCase, @Nonnull final WireMockRuntim
sut.createHttpClient(dest).execute(new HttpGet("/foo"), new BasicHttpClientResponseHandler());

var request = getRequestedFor(anyUrl()).andMatching(allowedHeaders(testCase.assertion.headersAllowed));
testCase.assertion.headersForbidden.forEach(request::withoutHeader);
testCase.assertion.headersRequired.forEach(( k, v ) -> request.withHeader(k, equalTo(v)));
verify(request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,6 @@ final class PreparedEntityBluePrint
@Nonnull
private final JDefinedClass entityClass;

/**
Copy link
Contributor

@newtork newtork Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor)

Drive-by / Unrelated change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this is part of the "Drive-by Java 23 compatibility"

* The more concrete sub-interface of the {@link com.sap.cloud.sdk.datamodel.odata.helper.EntitySelectable
* EntitySelectable} interface for this entity.
*/
/*@Nullable // in case of "POJO only"
private final JDefinedClass selectableInterface;*/

/**
* The concrete sub-class of the {@link com.sap.cloud.sdk.datamodel.odata.helper.EntityLink EntityLink} class for
* this entity used for one-to-many links.
*/
/*@Nullable // in case of "POJO only"
private final JDefinedClass entityOneToManyLinkClass;
*/
/**
* The concrete sub-class of the {@link com.sap.cloud.sdk.datamodel.odata.helper.EntityLink EntityLink} class for
* this entity used for one-to–one links.
*/
/*@Nullable // in case of "POJO only"
private final JDefinedClass entityOneToOneLinkClass;*/

/**
* A list containing all navigation properties that should be added to the entity.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ static void createBasicServiceInterfaceField(
}
}

/**
* Adds javadoc and annotations regarding states such as deprecation if necessary.
*
* @param affectedClass
* The class to add information to.
* @param service
* The service to take the status information from.
*
*/

/**
* Adds javadoc and annotations regarding states such as deprecation if necessary.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sap.cloud.sdk.services.openapi.apiclient;

import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.ok;
Expand Down Expand Up @@ -137,8 +136,8 @@ void testHttpRequestConfigIsTransmitted( WireMockRuntimeInfo wm )
httpRequest(TlsUpgrade.DISABLED, wm.getHttpBaseUrl());
verify(getRequestedFor(anyUrl()).withoutHeader("Upgrade"));

httpRequest(TlsUpgrade.ENABLED, wm.getHttpBaseUrl());
verify(getRequestedFor(anyUrl()).withHeader("Upgrade", equalTo("TLS/1.2")));
httpRequest(TlsUpgrade.AUTOMATIC, wm.getHttpBaseUrl());
verify(getRequestedFor(anyUrl()).withoutHeader("Upgrade"));
}

private static void httpRequest( TlsUpgrade toggle, String url )
Expand Down
2 changes: 1 addition & 1 deletion dependency-bundles/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<!-- HTTP stuff -->
<httpcore.version>4.4.16</httpcore.version>
<httpcore5.version>5.3.3</httpcore5.version>
<httpclient5.version>5.4.1</httpclient5.version>
<httpclient5.version>5.4.2</httpclient5.version>
<httpcomponents-client.version>4.5.14</httpcomponents-client.version>
<jakarta-servlet.version>6.1.0</jakarta-servlet.version>
<!-- XSUAA -->
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,12 @@
<arg>-Xlint:all</arg>
<arg>-Xlint:-processing</arg>
</compilerArgs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor)

Drive-by / Unrelated change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, this is part of the "Drive-by Java 23 compatibility"

</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
Expand Down
6 changes: 5 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

### 🔧 Compatibility Notes

-
- The TLS `Upgrade` header changes thanks to [Apache httpclient5 5.4.2](https://github.com/apache/httpcomponents-client/commit/5ab09ea39fed1c39ea35905532ba1567c785330a)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor)

Please rephrase ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better now?

- `TlsUpgrade.DISABLED` no changes
- `TlsUpgrade.ENABLED` will not send the `Upgrade` header for non-proxy connections anymore
- `TlsUpgrade.AUTOMATIC` **Default behaviour** will not send the `Upgrade` header anymore
- Except for `proxyType(ProxyType.INTERNET)`

### ✨ New Functionality

Expand Down
Loading