summaryrefslogtreecommitdiff
path: root/adservices/tests/cts/src/android
diff options
context:
space:
mode:
Diffstat (limited to 'adservices/tests/cts/src/android')
-rw-r--r--adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java17
-rw-r--r--adservices/tests/cts/src/android/adservices/cts/FledgeCtsTest.java277
-rw-r--r--adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java8
-rw-r--r--adservices/tests/cts/src/android/adservices/cts/TrustedBiddingDataTest.java15
-rw-r--r--adservices/tests/cts/src/android/adservices/debuggablects/FledgeCtsDebuggableTest.java101
5 files changed, 71 insertions, 347 deletions
diff --git a/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java b/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java
index 09cddae1b8..23714139a4 100644
--- a/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java
+++ b/adservices/tests/cts/src/android/adservices/cts/CustomAudienceApiCtsTest.java
@@ -41,7 +41,6 @@ import androidx.test.platform.app.InstrumentationRegistry;
import com.android.adservices.service.PhFlagsFixture;
import com.android.adservices.service.devapi.DevContext;
import com.android.adservices.service.devapi.DevContextFilter;
-import com.android.compatibility.common.util.ShellUtils;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
@@ -83,20 +82,10 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTest {
DevContext devContext = DevContextFilter.create(sContext).createDevContext(Process.myUid());
mIsDebugMode = devContext.getDevOptionsEnabled();
+ // Needed to test different custom audience limits
InstrumentationRegistry.getInstrumentation()
.getUiAutomation()
.adoptShellPermissionIdentity(Manifest.permission.WRITE_DEVICE_CONFIG);
- // Override rate limiting throttle on API calls
- PhFlagsFixture.overrideSdkRequestPermitsPerSecond(Integer.MAX_VALUE);
- // Disable the enrollment check, by default
- PhFlagsFixture.overrideFledgeEnrollmentCheck(false);
- // We need to turn the Consent Manager into debug mode
- overrideConsentManagerDebugMode();
- }
-
- // Override the Consent Manager behaviour - Consent Given
- private void overrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode true");
}
@Test
@@ -110,8 +99,6 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTest {
@Test
public void testJoinCustomAudience_withMissingEnrollment_fail() {
- PhFlagsFixture.overrideFledgeEnrollmentCheck(true);
-
Exception exception =
assertThrows(
ExecutionException.class,
@@ -321,8 +308,6 @@ public class CustomAudienceApiCtsTest extends ForegroundCtsTest {
@Test
public void testLeaveCustomAudience_withMissingEnrollment_fail() {
- PhFlagsFixture.overrideFledgeEnrollmentCheck(true);
-
Exception exception =
assertThrows(
ExecutionException.class,
diff --git a/adservices/tests/cts/src/android/adservices/cts/FledgeCtsTest.java b/adservices/tests/cts/src/android/adservices/cts/FledgeCtsTest.java
deleted file mode 100644
index ba37d690d0..0000000000
--- a/adservices/tests/cts/src/android/adservices/cts/FledgeCtsTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2022 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * 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
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.adservices.cts;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.junit.Assert.assertThrows;
-
-import android.Manifest;
-import android.adservices.adselection.AdSelectionConfig;
-import android.adservices.adselection.AdSelectionConfigFixture;
-import android.adservices.adselection.AddAdSelectionOverrideRequest;
-import android.adservices.clients.adselection.AdSelectionClient;
-import android.adservices.clients.adselection.TestAdSelectionClient;
-import android.adservices.clients.customaudience.AdvertisingCustomAudienceClient;
-import android.adservices.clients.customaudience.TestAdvertisingCustomAudienceClient;
-import android.adservices.common.AdData;
-import android.adservices.common.AdSelectionSignals;
-import android.adservices.common.AdTechIdentifier;
-import android.adservices.common.CommonFixture;
-import android.adservices.customaudience.AddCustomAudienceOverrideRequest;
-import android.adservices.customaudience.CustomAudience;
-import android.adservices.customaudience.CustomAudienceFixture;
-import android.adservices.customaudience.TrustedBiddingDataFixture;
-import android.net.Uri;
-import android.os.Process;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-
-import com.android.adservices.service.PhFlagsFixture;
-import com.android.adservices.service.common.Throttler;
-import com.android.adservices.service.devapi.DevContext;
-import com.android.adservices.service.devapi.DevContextFilter;
-import com.android.compatibility.common.util.ShellUtils;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
-
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-public class FledgeCtsTest extends ForegroundCtsTest {
- private static final Executor CALLBACK_EXECUTOR = Executors.newCachedThreadPool();
-
- private static final AdTechIdentifier BUYER_1 = AdSelectionConfigFixture.BUYER_1;
- private static final AdTechIdentifier BUYER_2 = AdSelectionConfigFixture.BUYER_2;
-
- private static final String SELLER_DECISION_LOGIC_URI = "/ssp/decision/logic/";
- private static final String BUYER_BIDDING_LOGIC_URI_PREFIX = "/buyer/bidding/logic/";
- private static final Uri TRUSTED_SCORING_SIGNALS_URI = Uri.parse("ssp/trusted/signals");
- private static final AdSelectionSignals TRUSTED_SCORING_SIGNALS =
- AdSelectionSignals.fromString(
- "{\n"
- + "\t\"render_uri_1\": \"signals_for_1\",\n"
- + "\t\"render_uri_2\": \"signals_for_2\"\n"
- + "}");
-
- private static final AdTechIdentifier SELLER = AdTechIdentifier.fromString("test.com");
- private static final String SELLER_REPORTING_PATH = "/reporting/seller";
- private static final String BUYER_REPORTING_PATH = "/reporting/buyer";
-
- private static final AdSelectionConfig AD_SELECTION_CONFIG =
- AdSelectionConfigFixture.anAdSelectionConfigBuilder()
- .setCustomAudienceBuyers(Arrays.asList(BUYER_1, BUYER_2))
- .setSeller(SELLER)
- .setDecisionLogicUri(
- Uri.parse("https://" + SELLER + "/" + SELLER_DECISION_LOGIC_URI))
- .setTrustedScoringSignalsUri(
- Uri.parse("https://" + SELLER + "/" + TRUSTED_SCORING_SIGNALS_URI))
- .build();
-
- private static final int DELAY_TO_AVOID_THROTTLE_MS = 1001;
- private AdSelectionClient mAdSelectionClient;
- private TestAdSelectionClient mTestAdSelectionClient;
- private AdvertisingCustomAudienceClient mCustomAudienceClient;
- private TestAdvertisingCustomAudienceClient mTestCustomAudienceClient;
- private DevContext mDevContext;
- private boolean mIsDebugMode;
-
- @Before
- public void setup() {
- assertForegroundActivityStarted();
-
- mAdSelectionClient =
- new AdSelectionClient.Builder()
- .setContext(sContext)
- .setExecutor(CALLBACK_EXECUTOR)
- .build();
- mTestAdSelectionClient =
- new TestAdSelectionClient.Builder()
- .setContext(sContext)
- .setExecutor(CALLBACK_EXECUTOR)
- .build();
- mCustomAudienceClient =
- new AdvertisingCustomAudienceClient.Builder()
- .setContext(sContext)
- .setExecutor(MoreExecutors.directExecutor())
- .build();
- mTestCustomAudienceClient =
- new TestAdvertisingCustomAudienceClient.Builder()
- .setContext(sContext)
- .setExecutor(MoreExecutors.directExecutor())
- .build();
- mDevContext = DevContextFilter.create(sContext).createDevContext(Process.myUid());
- mIsDebugMode = mDevContext.getDevOptionsEnabled();
-
- InstrumentationRegistry.getInstrumentation()
- .getUiAutomation()
- .adoptShellPermissionIdentity(Manifest.permission.WRITE_DEVICE_CONFIG);
- // Enabling tests to run with WebView version < M105
- PhFlagsFixture.overrideEnforceIsolateMaxHeapSize(false);
- PhFlagsFixture.overrideIsolateMaxHeapSizeBytes(0);
- PhFlagsFixture.overrideSdkRequestPermitsPerSecond(Integer.MAX_VALUE);
- // We need to turn the Consent Manager into debug mode
- overrideConsentManagerDebugMode();
- }
-
- // Override the Consent Manager behaviour - Consent Given
- private void overrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode true");
- }
-
- @Test
- public void testFledgeFlowFailsInNonDebuggableState() throws Exception {
- Assume.assumeFalse(mIsDebugMode);
-
- String decisionLogicJs =
- "function scoreAd(ad, bid, auction_config, seller_signals,"
- + " trusted_scoring_signals, contextual_signal, user_signal,"
- + " custom_audience_signal) { \n"
- + " return {'status': 0, 'score': bid };\n"
- + "}\n"
- + "function reportResult(ad_selection_config, render_uri, bid,"
- + " contextual_signals) { \n"
- + " return {'status': 0, 'results': {'signals_for_buyer':"
- + " '{\"signals_for_buyer\":1}', 'reporting_uri': '"
- + SELLER_REPORTING_PATH
- + "' } };\n"
- + "}";
-
- String biddingLogicJs =
- "function generateBid(ad, auction_signals, per_buyer_signals,"
- + " trusted_bidding_signals, contextual_signals, user_signals,"
- + " custom_audience_signals) { \n"
- + " return {'status': 0, 'ad': ad, 'bid': ad.metadata.result };\n"
- + "}\n"
- + "function reportWin(ad_selection_signals, per_buyer_signals,"
- + " signals_for_buyer, contextual_signals, custom_audience_signals) { \n"
- + " return {'status': 0, 'results': {'reporting_uri': '"
- + BUYER_REPORTING_PATH
- + "' } };\n"
- + "}";
-
- List<Double> bidsForBuyer1 = ImmutableList.of(1.1, 2.2);
- List<Double> bidsForBuyer2 = ImmutableList.of(4.5, 6.7, 10.0);
-
- CustomAudience customAudience1 = createCustomAudience(BUYER_1, bidsForBuyer1);
-
- CustomAudience customAudience2 = createCustomAudience(BUYER_2, bidsForBuyer2);
-
- Throttler.destroyExistingThrottler();
- // Joining custom audiences, no result to do assertion on. Failures will generate an
- // exception."
- Thread.sleep(DELAY_TO_AVOID_THROTTLE_MS);
- mCustomAudienceClient.joinCustomAudience(customAudience1).get(10, TimeUnit.SECONDS);
- Thread.sleep(DELAY_TO_AVOID_THROTTLE_MS);
- mCustomAudienceClient.joinCustomAudience(customAudience2).get(10, TimeUnit.SECONDS);
-
- // Adding AdSelection override, asserting a failure since app is not debuggable.
- AddAdSelectionOverrideRequest addAdSelectionOverrideRequest =
- new AddAdSelectionOverrideRequest(
- AD_SELECTION_CONFIG, decisionLogicJs, TRUSTED_SCORING_SIGNALS);
-
- ListenableFuture<Void> adSelectionOverrideResult =
- mTestAdSelectionClient.overrideAdSelectionConfigRemoteInfo(
- addAdSelectionOverrideRequest);
-
- Exception adSelectionOverrideException =
- assertThrows(
- ExecutionException.class,
- () -> adSelectionOverrideResult.get(10, TimeUnit.SECONDS));
- assertThat(adSelectionOverrideException.getCause()).isInstanceOf(SecurityException.class);
-
- AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest =
- new AddCustomAudienceOverrideRequest.Builder()
- .setBuyer(customAudience2.getBuyer())
- .setName(customAudience2.getName())
- .setBiddingLogicJs(biddingLogicJs)
- .setTrustedBiddingSignals(AdSelectionSignals.EMPTY)
- .build();
-
- // Adding Custom audience override, asserting a failure since app is not debuggable.
- ListenableFuture<Void> customAudienceOverrideResult =
- mTestCustomAudienceClient.overrideCustomAudienceRemoteInfo(
- addCustomAudienceOverrideRequest);
-
- Exception customAudienceOverrideException =
- assertThrows(
- ExecutionException.class,
- () -> customAudienceOverrideResult.get(10, TimeUnit.SECONDS));
- assertThat(customAudienceOverrideException.getCause())
- .isInstanceOf(SecurityException.class);
-
- // Running ad selection and asserting that a failure is returned since the fetch calls
- // should fail.
- Exception selectAdsException =
- assertThrows(
- ExecutionException.class,
- () ->
- mAdSelectionClient
- .selectAds(AD_SELECTION_CONFIG)
- .get(30, TimeUnit.SECONDS));
- assertThat(selectAdsException.getCause()).isInstanceOf(IllegalStateException.class);
- // Cannot perform reporting since no ad selection id is returned.
- }
-
- /**
- * @param buyer The name of the buyer for this Custom Audience
- * @param bids these bids, are added to its metadata. Our JS logic then picks this value and
- * creates ad with the provided value as bid
- * @return a real Custom Audience object that can be persisted and used in bidding and scoring
- */
- private CustomAudience createCustomAudience(final AdTechIdentifier buyer, List<Double> bids) {
-
- // Generate ads for with bids provided
- List<AdData> ads = new ArrayList<>();
-
- // Create ads with the buyer name and bid number as the ad URI
- // Add the bid value to the metadata
- for (int i = 0; i < bids.size(); i++) {
- ads.add(
- new AdData.Builder()
- .setRenderUri(CommonFixture.getUri(buyer, "/ad" + (i + 1)))
- .setMetadata("{\"result\":" + bids.get(i) + "}")
- .build());
- }
-
- return new CustomAudience.Builder()
- .setBuyer(buyer)
- .setName(buyer + CustomAudienceFixture.VALID_NAME)
- .setActivationTime(CustomAudienceFixture.VALID_ACTIVATION_TIME)
- .setExpirationTime(CustomAudienceFixture.VALID_EXPIRATION_TIME)
- .setDailyUpdateUri(CustomAudienceFixture.getValidDailyUpdateUriByBuyer(buyer))
- .setUserBiddingSignals(CustomAudienceFixture.VALID_USER_BIDDING_SIGNALS)
- .setTrustedBiddingData(
- TrustedBiddingDataFixture.getValidTrustedBiddingDataByBuyer(buyer))
- .setBiddingLogicUri(
- CommonFixture.getUri(
- buyer, BUYER_BIDDING_LOGIC_URI_PREFIX + buyer.toString()))
- .setAds(ads)
- .build();
- }
-}
diff --git a/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java b/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java
index 2ca1e888c4..139a3cfb58 100644
--- a/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java
+++ b/adservices/tests/cts/src/android/adservices/cts/TestAdSelectionManagerTest.java
@@ -40,7 +40,6 @@ import com.android.adservices.LogUtil;
import com.android.adservices.service.PhFlagsFixture;
import com.android.adservices.service.devapi.DevContext;
import com.android.adservices.service.devapi.DevContextFilter;
-import com.android.compatibility.common.util.ShellUtils;
import com.google.common.util.concurrent.ListenableFuture;
@@ -97,13 +96,6 @@ public class TestAdSelectionManagerTest extends ForegroundCtsTest {
.adoptShellPermissionIdentity(Manifest.permission.WRITE_DEVICE_CONFIG);
PhFlagsFixture.overrideEnforceIsolateMaxHeapSize(false);
PhFlagsFixture.overrideIsolateMaxHeapSizeBytes(0);
- // We need to turn the Consent Manager into debug mode
- overrideConsentManagerDebugMode();
- }
-
- // Override the Consent Manager behaviour - Consent Given
- private void overrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode true");
}
@Test
diff --git a/adservices/tests/cts/src/android/adservices/cts/TrustedBiddingDataTest.java b/adservices/tests/cts/src/android/adservices/cts/TrustedBiddingDataTest.java
index c26a6dbdd1..71f79aac48 100644
--- a/adservices/tests/cts/src/android/adservices/cts/TrustedBiddingDataTest.java
+++ b/adservices/tests/cts/src/android/adservices/cts/TrustedBiddingDataTest.java
@@ -44,13 +44,14 @@ public final class TrustedBiddingDataTest {
TrustedBiddingData validTrustedBiddingData =
new TrustedBiddingData.Builder()
.setTrustedBiddingUri(VALID_TRUSTED_BIDDING_URL)
- .setTrustedBiddingKeys(TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS)
+ .setTrustedBiddingKeys(
+ TrustedBiddingDataFixture.getValidTrustedBiddingKeys())
.build();
assertThat(validTrustedBiddingData.getTrustedBiddingUri())
.isEqualTo(VALID_TRUSTED_BIDDING_URL);
assertThat(validTrustedBiddingData.getTrustedBiddingKeys())
- .isEqualTo(TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS);
+ .isEqualTo(TrustedBiddingDataFixture.getValidTrustedBiddingKeys());
}
@Test
@@ -58,7 +59,8 @@ public final class TrustedBiddingDataTest {
TrustedBiddingData validTrustedBiddingData =
new TrustedBiddingData.Builder()
.setTrustedBiddingUri(VALID_TRUSTED_BIDDING_URL)
- .setTrustedBiddingKeys(TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS)
+ .setTrustedBiddingKeys(
+ TrustedBiddingDataFixture.getValidTrustedBiddingKeys())
.build();
Parcel p = Parcel.obtain();
@@ -68,7 +70,7 @@ public final class TrustedBiddingDataTest {
assertThat(fromParcel.getTrustedBiddingUri()).isEqualTo(VALID_TRUSTED_BIDDING_URL);
assertThat(fromParcel.getTrustedBiddingKeys())
- .isEqualTo(TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS);
+ .isEqualTo(TrustedBiddingDataFixture.getValidTrustedBiddingKeys());
}
@Test
@@ -79,7 +81,7 @@ public final class TrustedBiddingDataTest {
// TrustedBiddingUrl is not set, so it gets built as null
new TrustedBiddingData.Builder()
.setTrustedBiddingKeys(
- TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS)
+ TrustedBiddingDataFixture.getValidTrustedBiddingKeys())
.build();
});
}
@@ -118,7 +120,8 @@ public final class TrustedBiddingDataTest {
TrustedBiddingData validTrustedBiddingData =
new TrustedBiddingData.Builder()
.setTrustedBiddingUri(VALID_TRUSTED_BIDDING_URL)
- .setTrustedBiddingKeys(TrustedBiddingDataFixture.VALID_TRUSTED_BIDDING_KEYS)
+ .setTrustedBiddingKeys(
+ TrustedBiddingDataFixture.getValidTrustedBiddingKeys())
.build();
assertThat(validTrustedBiddingData.describeContents()).isEqualTo(0);
diff --git a/adservices/tests/cts/src/android/adservices/debuggablects/FledgeCtsDebuggableTest.java b/adservices/tests/cts/src/android/adservices/debuggablects/FledgeCtsDebuggableTest.java
index a81366ac4c..5862986bca 100644
--- a/adservices/tests/cts/src/android/adservices/debuggablects/FledgeCtsDebuggableTest.java
+++ b/adservices/tests/cts/src/android/adservices/debuggablects/FledgeCtsDebuggableTest.java
@@ -40,14 +40,13 @@ import android.adservices.customaudience.CustomAudienceFixture;
import android.adservices.customaudience.TrustedBiddingDataFixture;
import android.net.Uri;
import android.os.Process;
+import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry;
-import com.android.adservices.LogUtil;
import com.android.adservices.service.PhFlagsFixture;
import com.android.adservices.service.devapi.DevContext;
import com.android.adservices.service.devapi.DevContextFilter;
-import com.android.compatibility.common.util.ShellUtils;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.MoreExecutors;
@@ -69,6 +68,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
+ public static final String TAG = "adservices";
// Time allowed by current test setup for APIs to respond
private static final int API_RESPONSE_TIMEOUT_SECONDS = 5;
@@ -90,6 +90,9 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
private static final String SELLER_REPORTING_PATH = "/reporting/seller";
private static final String BUYER_REPORTING_PATH = "/reporting/buyer";
+ private static final String SELLER_REPORTING_URI =
+ String.format("https://%s%s", AdSelectionConfigFixture.SELLER, SELLER_REPORTING_PATH);
+
private static final String DEFAULT_DECISION_LOGIC_JS =
"function scoreAd(ad, bid, auction_config, seller_signals,"
+ " trusted_scoring_signals, contextual_signal, user_signal,"
@@ -100,7 +103,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
+ " contextual_signals) { \n"
+ " return {'status': 0, 'results': {'signals_for_buyer':"
+ " '{\"signals_for_buyer\":1}', 'reporting_uri': '"
- + SELLER_REPORTING_PATH
+ + SELLER_REPORTING_URI
+ "' } };\n"
+ "}";
private static final AdSelectionSignals TRUSTED_SCORING_SIGNALS =
@@ -136,16 +139,36 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
AdSelectionConfigFixture.SELLER,
SELLER_TRUSTED_SIGNAL_URI_PATH)))
.build();
- private static final String DEFAULT_BIDDING_LOGIC_JS =
+
+ private static final String BUYER_2_REPORTING_URI =
+ String.format("https://%s%s", AdSelectionConfigFixture.BUYER_2, BUYER_REPORTING_PATH);
+
+ private static final String BUYER_2_BIDDING_LOGIC_JS =
+ "function generateBid(ad, auction_signals, per_buyer_signals,"
+ + " trusted_bidding_signals, contextual_signals,"
+ + " custom_audience_signals) { \n"
+ + " return {'status': 0, 'ad': ad, 'bid': ad.metadata.result };\n"
+ + "}\n"
+ + "function reportWin(ad_selection_signals, per_buyer_signals,"
+ + " signals_for_buyer, contextual_signals, custom_audience_signals) { \n"
+ + " return {'status': 0, 'results': {'reporting_uri': '"
+ + BUYER_2_REPORTING_URI
+ + "' } };\n"
+ + "}";
+
+ private static final String BUYER_1_REPORTING_URI =
+ String.format("https://%s%s", AdSelectionConfigFixture.BUYER_1, BUYER_REPORTING_PATH);
+
+ private static final String BUYER_1_BIDDING_LOGIC_JS =
"function generateBid(ad, auction_signals, per_buyer_signals,"
- + " trusted_bidding_signals, contextual_signals, user_signals,"
+ + " trusted_bidding_signals, contextual_signals,"
+ " custom_audience_signals) { \n"
+ " return {'status': 0, 'ad': ad, 'bid': ad.metadata.result };\n"
+ "}\n"
+ "function reportWin(ad_selection_signals, per_buyer_signals,"
+ " signals_for_buyer, contextual_signals, custom_audience_signals) { \n"
+ " return {'status': 0, 'results': {'reporting_uri': '"
- + BUYER_REPORTING_PATH
+ + BUYER_1_REPORTING_URI
+ "' } };\n"
+ "}";
private AdSelectionClient mAdSelectionClient;
@@ -199,14 +222,6 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
// Enable CTS to be run with versions of WebView < M105
PhFlagsFixture.overrideEnforceIsolateMaxHeapSize(false);
PhFlagsFixture.overrideIsolateMaxHeapSizeBytes(0);
- PhFlagsFixture.overrideSdkRequestPermitsPerSecond(Integer.MAX_VALUE);
- // We need to turn the Consent Manager into debug mode
- overrideConsentManagerDebugMode();
- }
-
- // Override the Consent Manager behaviour - Consent Given
- private void overrideConsentManagerDebugMode() {
- ShellUtils.runShellCommand("setprop debug.adservices.consent_manager_debug_mode true");
}
@After
@@ -249,14 +264,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -269,9 +284,11 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
.overrideCustomAudienceRemoteInfo(addCustomAudienceOverrideRequest2)
.get(API_RESPONSE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
- LogUtil.i(
+ Log.i(
+ TAG,
"Running ad selection with logic URI " + AD_SELECTION_CONFIG.getDecisionLogicUri());
- LogUtil.i(
+ Log.i(
+ TAG,
"Decision logic URI domain is "
+ AD_SELECTION_CONFIG.getDecisionLogicUri().getHost());
@@ -327,7 +344,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience.getBuyer())
.setName(customAudience.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -337,9 +354,11 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
.overrideCustomAudienceRemoteInfo(addCustomAudienceOverrideRequest)
.get(API_RESPONSE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
- LogUtil.i(
+ Log.i(
+ TAG,
"Running ad selection with logic URI " + AD_SELECTION_CONFIG.getDecisionLogicUri());
- LogUtil.i(
+ Log.i(
+ TAG,
"Decision logic URI domain is "
+ AD_SELECTION_CONFIG.getDecisionLogicUri().getHost());
@@ -416,14 +435,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -499,14 +518,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -581,7 +600,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
@@ -659,14 +678,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -724,7 +743,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
// We do not provide override for CA 2, that should lead to failure to get biddingLogic
@@ -783,14 +802,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -861,14 +880,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -945,14 +964,14 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -1011,7 +1030,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
String jsWaitMoreThanAllowedForBiddingPerCa = insertJsWait(5000);
String readBidFromAdMetadataWithDelayJs =
"function generateBid(ad, auction_signals, per_buyer_signals,"
- + " trusted_bidding_signals, contextual_signals, user_signals,"
+ + " trusted_bidding_signals, contextual_signals,"
+ " custom_audience_signals) { \n"
+ jsWaitMoreThanAllowedForBiddingPerCa
+ " return {'status': 0, 'ad': ad, 'bid': ad.metadata.result };\n"
@@ -1031,7 +1050,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience1.getBuyer())
.setName(customAudience1.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_1_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
AddCustomAudienceOverrideRequest addCustomAudienceOverrideRequest2 =
@@ -1115,7 +1134,7 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
new AddCustomAudienceOverrideRequest.Builder()
.setBuyer(customAudience2.getBuyer())
.setName(customAudience2.getName())
- .setBiddingLogicJs(DEFAULT_BIDDING_LOGIC_JS)
+ .setBiddingLogicJs(BUYER_2_BIDDING_LOGIC_JS)
.setTrustedBiddingSignals(TRUSTED_BIDDING_SIGNALS)
.build();
@@ -1125,9 +1144,11 @@ public class FledgeCtsDebuggableTest extends ForegroundDebuggableCtsTest {
.overrideCustomAudienceRemoteInfo(addCustomAudienceOverrideRequest)
.get(API_RESPONSE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
- LogUtil.i(
+ Log.i(
+ TAG,
"Running ad selection with logic URI " + AD_SELECTION_CONFIG.getDecisionLogicUri());
- LogUtil.i(
+ Log.i(
+ TAG,
"Decision logic URI domain is "
+ AD_SELECTION_CONFIG.getDecisionLogicUri().getHost());