1616
1717package com.wultra.android.powerauth.networking
1818
19- import android.util.Log
2019import androidx.test.ext.junit.runners.AndroidJUnit4
2120import androidx.test.platform.app.InstrumentationRegistry
2221import com.wultra.android.powerauth.networking.data.BaseRequest
@@ -33,6 +32,7 @@ import io.getlime.security.powerauth.sdk.PowerAuthAuthentication
3332import okhttp3.OkHttpClient
3433import org.junit.Assert.assertEquals
3534import org.junit.Assert.assertNotNull
35+ import org.junit.Assert.assertNull
3636import org.junit.Assert.assertTrue
3737import org.junit.Assert.fail
3838import org.junit.Assume.assumeNotNull
@@ -47,16 +47,14 @@ import java.util.concurrent.TimeUnit
4747 *
4848 * These tests require a valid `config.json` in the androidTest assets
4949 * and a running PowerAuth server. Tests are skipped when the config is absent.
50- *
51- * Mirrors Apple's WPNPostIntegrationTests (success + failure suites).
5250 */
5351@RunWith(AndroidJUnit4 ::class )
5452class PostRealServerTest {
5553
5654 private fun loadConfigOrSkip (): TestConfiguration {
5755 val context = InstrumentationRegistry .getInstrumentation().targetContext
5856 val config = TestConfiguration .load(context)
59- assumeNotNull(" Skipping: config.json not found in test assets" , config)
57+ assumeNotNull(" ⚠ \uFE0F Skipping: config.json not found in test assets" , config)
6058 return config!!
6159 }
6260
@@ -65,9 +63,6 @@ class PostRealServerTest {
6563 /* *
6664 * Plain POST to jsonplaceholder.typicode.com.
6765 *
68- * Mirrors Apple's `plainPost()` test. Verifies that the HTTP transport
69- * layer works correctly by making a real network call.
70- *
7166 * The test expects an error because jsonplaceholder does not return
7267 * the WPN envelope format (`{"status":"OK", ...}`).
7368 */
@@ -106,32 +101,15 @@ class PostRealServerTest {
106101
107102 assertTrue(" Real network request should complete within 30s" , latch.await(30 , TimeUnit .SECONDS ))
108103
109- // jsonplaceholder returns 201 for POST /posts, but the body is not
110- // in WPN envelope format. The library should either:
111- // 1. Parse successfully (if the response happens to parse as StatusResponse)
112- // 2. Fail with a parse error (ApiHttpException wrapping a Gson error)
113- //
114- // The key assertion is that the request was actually sent and we got a response.
115- if (receivedError != null ) {
116- // Expected: transport succeeded but response format doesn't match
117- Log .d(" PostRealServerTest" , " Got expected error: ${receivedError!! .e} " )
118- val httpException = receivedError!! .e as ? ApiHttpException
119- if (httpException != null ) {
120- // If it's an HTTP exception, the status code should be 201 (Created)
121- assertEquals(201 , httpException.code)
122- }
123- // Otherwise it's a parse error, which is also acceptable
124- } else {
125- // If parsing somehow succeeded, the status might be null/unexpected
126- Log .d(" PostRealServerTest" , " Got response: ${receivedResponse?.status} " )
127- }
104+ assertNull(" Response should be null because JSONPlaceholder response does not match StatusResponse" , receivedResponse?.status)
105+
106+ assertNull(" Request should not fail on transport level" , receivedError)
128107 }
129108
130109 // --- Success tests (require config.json) ---
131110
132111 /* *
133112 * E2EE POST with application scope encryption.
134- * Mirrors Apple's `e2eePost()` test.
135113 */
136114 @Test
137115 fun e2eePost () {
@@ -178,7 +156,6 @@ class PostRealServerTest {
178156
179157 /* *
180158 * Signed POST with PowerAuth signature.
181- * Mirrors Apple's `signedPost()` test.
182159 */
183160 @Test
184161 fun signedPost () {
@@ -267,7 +244,6 @@ class PostRealServerTest {
267244
268245 /* *
269246 * E2EE POST with activation scope without activation.
270- * Mirrors Apple's `e2eePostUnactivated()` test.
271247 */
272248 @Test
273249 fun e2eePostUnactivated () {
@@ -308,7 +284,6 @@ class PostRealServerTest {
308284
309285 /* *
310286 * Signed POST with wrong PIN.
311- * Mirrors Apple's `signedPostWrongPin()` test.
312287 */
313288 @Test
314289 fun signedPostWrongPin () {
0 commit comments