Skip to content

Commit 89da889

Browse files
Seamless handling of Cross-level consumption of destination-fragment pairs
1 parent 9963244 commit 89da889

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class TransparentProxyDestination implements HttpDestination
3737
static final String TENANT_SUBDOMAIN_HEADER_KEY = "x-tenant-subdomain";
3838
static final String TENANT_ID_HEADER_KEY = "x-tenant-id";
3939
static final String FRAGMENT_OPTIONAL_HEADER_KEY = "x-fragment-optional";
40+
static final String DESTINATION_LEVEL_HEADER_KEY = "x-destination-level";
41+
static final String FRAGMENT_LEVEL_HEADER_KEY = "x-fragment-level";
4042
static final String TOKEN_SERVICE_TENANT_HEADER_KEY = "x-token-service-tenant";
4143
static final String CLIENT_ASSERTION_HEADER_KEY = "x-client-assertion";
4244
static final String CLIENT_ASSERTION_TYPE_HEADER_KEY = "x-client-assertion-type";
@@ -673,6 +675,36 @@ public DynamicBuilder fragmentName( @Nonnull final String fragmentName )
673675
return header(new Header(FRAGMENT_NAME_HEADER_KEY, fragmentName));
674676
}
675677

678+
/**
679+
* Sets the destination level for the dynamic destination. See
680+
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations
681+
*
682+
* @param destinationLevel
683+
* The level of the destination to use.
684+
* @return This builder instance for method chaining.
685+
*/
686+
@Nonnull
687+
public DynamicBuilder destinationLevel(
688+
@Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope destinationLevel )
689+
{
690+
return header(new Header(DESTINATION_LEVEL_HEADER_KEY, destinationLevel.toString()));
691+
}
692+
693+
/**
694+
* Sets the fragment level for the dynamic destination. See
695+
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations
696+
*
697+
* @param fragmentLevel
698+
* The level of the fragment to use.
699+
* @return This builder instance for method chaining.
700+
*/
701+
@Nonnull
702+
public DynamicBuilder fragmentLevel(
703+
@Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope fragmentLevel )
704+
{
705+
return header(new Header(FRAGMENT_LEVEL_HEADER_KEY, fragmentLevel.toString()));
706+
}
707+
676708
/**
677709
* Sets the fragment optional flag for the dynamic destination. See
678710
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class TransparentProxyDestinationTest
2929
private static final String TEST_TENANT_SUBDOMAIN = "subdomainValue";
3030
private static final String TEST_TENANT_ID = "tenantIdValue";
3131
private static final String TEST_AUTHORIZATION_HEADER = "dummy-jwt-token";
32+
private static final String SUBACCOUNT_LEVEL = "subaccount";
33+
private static final String PROVIDER_SUBACCOUNT_LEVEL = "provider_subaccount";
3234

3335
@Test
3436
void testGetDelegationDestination()
@@ -75,14 +77,18 @@ void testDynamicDestinationHeaders()
7577
final TransparentProxyDestination destination =
7678
TransparentProxyDestination
7779
.dynamicDestination(TEST_DEST_NAME, VALID_URI.toString())
80+
.destinationLevel(SUBACCOUNT_LEVEL)
7881
.fragmentName("fragName")
82+
.fragmentLevel(PROVIDER_SUBACCOUNT_LEVEL)
7983
.fragmentOptional(true)
8084
.build();
8185

8286
assertThat(destination.getHeaders(VALID_URI))
8387
.contains(
8488
new Header(TransparentProxyDestination.DESTINATION_NAME_HEADER_KEY, TEST_DEST_NAME),
89+
new Header(TransparentProxyDestination.DESTINATION_LEVEL_HEADER_KEY, SUBACCOUNT_LEVEL),
8590
new Header(TransparentProxyDestination.FRAGMENT_NAME_HEADER_KEY, "fragName"),
91+
new Header(TransparentProxyDestination.FRAGMENT_LEVEL_HEADER_KEY, PROVIDER_SUBACCOUNT_LEVEL),
8692
new Header(TransparentProxyDestination.FRAGMENT_OPTIONAL_HEADER_KEY, "true"));
8793
}
8894

0 commit comments

Comments
 (0)