Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API. No auction response #123

Merged
merged 5 commits into from
Jul 30, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -231,6 +231,9 @@ protected void onPostExecute(AsyncTaskResult<JSONObject> asyncTaskResult) {
if (asyncTaskResult.getError() != null) {
asyncTaskResult.getError().printStackTrace();

//Default error
notifyDemandFailed(ResultCode.PREBID_SERVER_ERROR);

removeThisTask();
return;
} else if (asyncTaskResult.getResultCode() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ public void testInvalidPrebidServerAccountIdForAppNexusHostedPrebidServer() {

@Test
public void testInvalidPrebidServerAccountIdForRubiconHostedPrebidServer() {
PrebidMobile.setPrebidServerHost(Host.RUBICON);
if (!successfulMockServerStarted) {
fail("Mock server was not started");
}
server.enqueue(new MockResponse().setResponseCode(400).setBody(MockPrebidServerResponses.invalidAccountIdFromRubicon()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);

PrebidMobile.setPrebidServerAccountId("1001_INVALID_ACCOUNT_ID");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
Expand All @@ -112,7 +119,9 @@ public void testInvalidPrebidServerAccountIdForRubiconHostedPrebidServer() {
adapter.requestDemand(requestParams, mockListener, uuid);
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();

verify(mockListener).onDemandFailed(ResultCode.INVALID_ACCOUNT_ID, uuid);

}

@Test
Expand All @@ -135,7 +144,15 @@ public void testInvalidPrebidServerConfigIdForAppNexusHostedPrebidServer() {

@Test
public void testInvalidPrebidServerConfigIdForRubiconHostedPrebidServer() {
PrebidMobile.setPrebidServerHost(Host.RUBICON);

if (!successfulMockServerStarted) {
fail("Mock server was not started");
}
server.enqueue(new MockResponse().setResponseCode(400).setBody(MockPrebidServerResponses.invalidConfigIdFromRubicon()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);

PrebidMobile.setPrebidServerAccountId("1001");
PrebidMobile.setShareGeoLocation(true);
PrebidMobile.setApplicationContext(activity.getApplicationContext());
Expand All @@ -148,6 +165,7 @@ public void testInvalidPrebidServerConfigIdForRubiconHostedPrebidServer() {
adapter.requestDemand(requestParams, mockListener, uuid);
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();

verify(mockListener).onDemandFailed(ResultCode.INVALID_CONFIG_ID, uuid);
}

Expand Down Expand Up @@ -769,6 +787,31 @@ public void testTargetingParamsInPostData() throws Exception {
}
}

@Test
public void testRubiconDefaultError() {
if (!successfulMockServerStarted) {
fail("Server failed to start, unable to test.");
}

server.enqueue(new MockResponse().setResponseCode(200).setBody(MockPrebidServerResponses.htmlUnreachableFromRubicon()));
HttpUrl hostUrl = server.url("/");
Host.CUSTOM.setHostUrl(hostUrl.toString());
PrebidMobile.setPrebidServerHost(Host.CUSTOM);
PrebidMobile.setPrebidServerAccountId("12345");
PrebidMobile.setApplicationContext(activity.getApplicationContext());
DemandAdapter.DemandAdapterListener mockListener = mock(DemandAdapter.DemandAdapterListener.class);
PrebidServerAdapter adapter = new PrebidServerAdapter();
HashSet<AdSize> sizes = new HashSet<>();
sizes.add(new AdSize(320, 50));
RequestParams requestParams = new RequestParams("67890", AdType.BANNER, sizes, new ArrayList<String>());
String uuid = UUID.randomUUID().toString();
adapter.requestDemand(requestParams, mockListener, uuid);
Robolectric.flushBackgroundThreadScheduler();
Robolectric.flushForegroundThreadScheduler();
verify(mockListener).onDemandFailed(ResultCode.PREBID_SERVER_ERROR, uuid);

}

@Test
public void testPostDataWithCOPPA() throws Exception {
if (!successfulMockServerStarted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ public static String noBidResponseTmaxTooLarge() {
return inputStreamToString(in);
}

public static String htmlUnreachableFromRubicon() {
InputStream in = MockPrebidServerResponses.class.getClassLoader().getResourceAsStream("PrebidServerHtmlUnreachableFromRubiconInvalidResponse.html");
return inputStreamToString(in);
}

public static String invalidAccountIdFromRubicon() {
InputStream in = MockPrebidServerResponses.class.getClassLoader().getResourceAsStream("PrebidServerInvalidAccountIdFromRubicon.json");
return inputStreamToString(in);
}

public static String invalidConfigIdFromRubicon() {
InputStream in = MockPrebidServerResponses.class.getClassLoader().getResourceAsStream("PrebidServerInvalidConfigIdFromRubicon.json");
return inputStreamToString(in);
}

public static String inputStreamToString(InputStream is) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<html><head><title>Temporarily Unreachable</title></head><body>Temporarily Unreachable</body></html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invalid request format: No stored request found for id: 1001_INVALID_ACCOUNT_ID
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invalid request format: No stored imp found for id: 1001-1_INVALID_CONFIG_ID