Skip to content

Commit 3c4239e

Browse files
author
softcoder594
committed
optable-targeting: Patch host macro params to use {{}} instead of {}
1 parent 413779f commit 3c4239e

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

extra/modules/optable-targeting/src/main/java/org/prebid/server/hooks/modules/optable/targeting/v1/net/APIClientImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public class APIClientImpl implements APIClient {
2727
private static final Logger logger = LoggerFactory.getLogger(APIClientImpl.class);
2828
private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger);
2929

30-
private static final String TENANT = "{TENANT}";
31-
private static final String ORIGIN = "{ORIGIN}";
30+
private static final String TENANT = "{{TENANT}}";
31+
private static final String ORIGIN = "{{ORIGIN}}";
3232

3333
private final String endpoint;
3434
private final HttpClient httpClient;

extra/modules/optable-targeting/src/test/java/org/prebid/server/hooks/modules/optable/targeting/v1/BaseOptableTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,6 @@ protected OptableTargetingProperties givenOptableTargetingProperties(String key,
245245
}
246246

247247
protected Query givenQuery() {
248-
return Query.of("que", "ry");
248+
return Query.of("?que", "ry");
249249
}
250250
}

extra/modules/optable-targeting/src/test/java/org/prebid/server/hooks/modules/optable/targeting/v1/net/APIClientImplTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,31 @@ public void shouldUseAuthorizationHeaderIfApiKeyIsPresent() {
153153
assertThat(result.result()).isNull();
154154
}
155155

156+
@Test
157+
public void shouldBuildApiUrlByReplacingTenantAndOriginMacros() {
158+
// given
159+
target = new APIClientImpl(
160+
"http://endpoint.optable.com?t={{TENANT}}&o={{ORIGIN}}",
161+
httpClient,
162+
jacksonMapper,
163+
10);
164+
165+
when(httpClient.get(any(), any(), anyLong()))
166+
.thenReturn(Future.succeededFuture(givenFailHttpResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR,
167+
"plain_text_response.json")));
168+
169+
// when
170+
final Future<TargetingResult> result = target.getTargeting(givenOptableTargetingProperties(false),
171+
givenQuery(), List.of("8.8.8.8"), timeout);
172+
173+
// then
174+
final ArgumentCaptor<String> endpointCaptor = ArgumentCaptor.forClass(String.class);
175+
verify(httpClient).get(endpointCaptor.capture(), any(), anyLong());
176+
assertThat(endpointCaptor.getValue())
177+
.isEqualTo("http://endpoint.optable.com?t=accountId&o=origin?query");
178+
assertThat(result.result()).isNull();
179+
}
180+
156181
@Test
157182
public void shouldNotUseAuthorizationHeaderIfApiKeyIsAbsent() {
158183
// given

sample/configs/prebid-config-with-optable.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ hooks:
5050
enabled: true
5151
modules:
5252
optable-targeting:
53-
api-endpoint: https://na.edge.optable.co/v2/targeting?t={TENANT}&o={ORIGIN}
53+
api-endpoint: https://na.edge.optable.co/v2/targeting?t={{TENANT}}&o={{ORIGIN}}

0 commit comments

Comments
 (0)