@@ -33,6 +33,7 @@ import io.getlime.security.powerauth.sdk.PowerAuthAuthentication
3333import okhttp3.OkHttpClient
3434import org.junit.Assert.assertEquals
3535import org.junit.Assert.assertNotNull
36+ import org.junit.Assert.assertNull
3637import org.junit.Assert.assertTrue
3738import org.junit.Assert.fail
3839import org.junit.Assume.assumeNotNull
@@ -47,16 +48,14 @@ import java.util.concurrent.TimeUnit
4748 *
4849 * These tests require a valid `config.json` in the androidTest assets
4950 * and a running PowerAuth server. Tests are skipped when the config is absent.
50- *
51- * Mirrors Apple's WPNPostIntegrationTests (success + failure suites).
5251 */
5352@RunWith(AndroidJUnit4 ::class )
5453class PostRealServerTest {
5554
5655 private fun loadConfigOrSkip (): TestConfiguration {
5756 val context = InstrumentationRegistry .getInstrumentation().targetContext
5857 val config = TestConfiguration .load(context)
59- assumeNotNull(" Skipping: config.json not found in test assets" , config)
58+ assumeNotNull(" ⚠ \uFE0F Skipping: config.json not found in test assets" , config)
6059 return config!!
6160 }
6261
@@ -65,9 +64,6 @@ class PostRealServerTest {
6564 /* *
6665 * Plain POST to jsonplaceholder.typicode.com.
6766 *
68- * Mirrors Apple's `plainPost()` test. Verifies that the HTTP transport
69- * layer works correctly by making a real network call.
70- *
7167 * The test expects an error because jsonplaceholder does not return
7268 * the WPN envelope format (`{"status":"OK", ...}`).
7369 */
@@ -106,32 +102,15 @@ class PostRealServerTest {
106102
107103 assertTrue(" Real network request should complete within 30s" , latch.await(30 , TimeUnit .SECONDS ))
108104
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- }
105+ assertNull(" Response should be null because JSONPlaceholder response does not match StatusResponse" , receivedResponse?.status)
106+
107+ assertNull(" Request should not fail on transport level" , receivedError)
128108 }
129109
130110 // --- Success tests (require config.json) ---
131111
132112 /* *
133113 * E2EE POST with application scope encryption.
134- * Mirrors Apple's `e2eePost()` test.
135114 */
136115 @Test
137116 fun e2eePost () {
@@ -178,7 +157,6 @@ class PostRealServerTest {
178157
179158 /* *
180159 * Signed POST with PowerAuth signature.
181- * Mirrors Apple's `signedPost()` test.
182160 */
183161 @Test
184162 fun signedPost () {
@@ -267,7 +245,6 @@ class PostRealServerTest {
267245
268246 /* *
269247 * E2EE POST with activation scope without activation.
270- * Mirrors Apple's `e2eePostUnactivated()` test.
271248 */
272249 @Test
273250 fun e2eePostUnactivated () {
@@ -308,7 +285,6 @@ class PostRealServerTest {
308285
309286 /* *
310287 * Signed POST with wrong PIN.
311- * Mirrors Apple's `signedPostWrongPin()` test.
312288 */
313289 @Test
314290 fun signedPostWrongPin () {
0 commit comments