Skip to content

Commit aa3d017

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

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
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";
@@ -661,7 +663,7 @@ protected DynamicBuilder getThis()
661663

662664
/**
663665
* Sets the fragment name for the dynamic destination. See
664-
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations
666+
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destination
665667
*
666668
* @param fragmentName
667669
* The name of the fragment to use.
@@ -673,6 +675,34 @@ 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( @Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope destinationLevel )
688+
{
689+
return header(new Header(DESTINATION_LEVEL_HEADER_KEY, destinationLevel.toString()));
690+
}
691+
692+
/**
693+
* Sets the fragment level for the dynamic destination. See
694+
* https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations
695+
*
696+
* @param fragmentLevel
697+
* The level of the fragment to use.
698+
* @return This builder instance for method chaining.
699+
*/
700+
@Nonnull
701+
public DynamicBuilder fragmentLevel( @Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope fragmentLevel )
702+
{
703+
return header(new Header(FRAGMENT_LEVEL_HEADER_KEY, fragmentLevel.toString()));
704+
}
705+
676706
/**
677707
* Sets the fragment optional flag for the dynamic destination. See
678708
* 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)