Skip to content

Commit 0445fce

Browse files
Comment features that are not supported at the moment (#1195)
Signed-off-by: Tomas Chladek <[email protected]>
1 parent e1d593c commit 0445fce

File tree

5 files changed

+68
-96
lines changed

5 files changed

+68
-96
lines changed

integration/agent/api/src/main/java/com/splunk/rum/integration/agent/api/network/SplunkNetworkRequest.kt

+10-39
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,25 @@ package com.splunk.rum.integration.agent.api.network
1919
import java.net.URL
2020

2121
data class SplunkNetworkRequest(
22-
var start: Long,
23-
var duration: Long,
22+
//var start: Long,
23+
//var duration: Long,
2424
var url: URL,
2525
var method: String,
26-
var protocol: String?,
27-
var initiator: String?,
28-
var status: Status,
26+
//var protocol: String?,
27+
//var initiator: String?,
28+
//var status: Status,
2929
var statusCode: Int,
30-
var cached: Boolean,
31-
var requestBody: String?,
32-
var responseBody: String?,
30+
//var cached: Boolean,
31+
//var requestBody: String?,
32+
//var responseBody: String?,
3333
var requestHeaders: MutableMap<String, MutableList<String>>?,
3434
var responseHeaders: MutableMap<String, MutableList<String>>?
3535
) {
3636

37-
constructor(
38-
duration: Long,
39-
url: URL,
40-
method: String,
41-
protocol: String?,
42-
initiator: String,
43-
status: Status,
44-
statusCode: Int,
45-
cached: Boolean,
46-
requestBody: String?,
47-
responseBody: String?,
48-
requestHeaders: MutableMap<String, MutableList<String>>? = null,
49-
responseHeaders: MutableMap<String, MutableList<String>>? = null
50-
) : this (
51-
start = System.currentTimeMillis(),
52-
duration = duration,
53-
url = url,
54-
method = method,
55-
protocol = protocol,
56-
initiator = initiator,
57-
status = status,
58-
statusCode = statusCode,
59-
cached = cached,
60-
requestBody = requestBody,
61-
responseBody = responseBody,
62-
requestHeaders = requestHeaders,
63-
responseHeaders = responseHeaders
64-
)
65-
66-
enum class Status(internal val code: String) {
37+
/*enum class Status(internal val code: String) {
6738
OK("ok"),
6839
ERROR("error"),
6940
ABORT("abort"),
7041
TIMEOUT("timeout")
71-
}
42+
}*/
7243
}

integration/okhttp/src/main/java/com/splunk/rum/integration/okhttp/OkHttpConnector.kt

+11-11
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ internal class OkHttpConnector(
8080
prefilteredInterceptedRequest = parseRequestAndResponse(
8181
start = start,
8282
duration = System.currentTimeMillis() - start,
83-
status = SplunkNetworkRequest.Status.ERROR,
83+
//status = SplunkNetworkRequest.Status.ERROR,
8484
request = request,
8585
response = null,
8686
connection = connection
@@ -95,7 +95,7 @@ internal class OkHttpConnector(
9595
prefilteredInterceptedRequest = parseRequestAndResponse(
9696
start = start,
9797
duration = System.currentTimeMillis() - start,
98-
status = SplunkNetworkRequest.Status.OK,
98+
//status = SplunkNetworkRequest.Status.OK,
9999
request = request,
100100
response = response,
101101
connection = connection
@@ -105,19 +105,19 @@ internal class OkHttpConnector(
105105
return response
106106
}
107107

108-
private fun parseRequestAndResponse(start: Long, duration: Long, status: SplunkNetworkRequest.Status, request: Request, response: Response?, connection: Connection?): SplunkNetworkRequest {
108+
private fun parseRequestAndResponse(start: Long, duration: Long, /*status: SplunkNetworkRequest.Status,*/ request: Request, response: Response?, connection: Connection?): SplunkNetworkRequest {
109109
return SplunkNetworkRequest(
110-
start = start,
111-
duration = duration,
110+
//start = start,
111+
//duration = duration,
112112
url = request.parseURL(),
113113
method = request.parseMethod(),
114-
protocol = connection?.parseProtocol(),
115-
initiator = initiator,
116-
status = status,
114+
//protocol = connection?.parseProtocol(),
115+
//initiator = initiator,
116+
//status = status,
117117
statusCode = response?.parseStatusCode() ?: UNKNOWN_STATUS_CODE,
118-
cached = response?.isCached() == true,
119-
requestBody = null,
120-
responseBody = null,
118+
//cached = response?.isCached() == true,
119+
//requestBody = null,
120+
//responseBody = null,
121121
requestHeaders = request.parseHeaders(),
122122
responseHeaders = response?.parseHeaders() ?: mutableMapOf()
123123
)

integration/okhttp/src/main/java/com/splunk/rum/integration/okhttp/interceptor/SplunkMaskBodyInterceptor.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import com.splunk.rum.integration.agent.api.network.SplunkNetworkRequest
2121
import com.splunk.rum.integration.okhttp.model.Mask
2222
import com.splunk.rum.integration.okhttp.model.SplunkChain
2323

24-
class SplunkMaskBodyInterceptor(
24+
// Not supported by a BE at the moment
25+
/*class SplunkMaskBodyInterceptor(
2526
val masks: List<Mask>
2627
) : SplunkOkHttpInterceptor {
2728
@@ -36,4 +37,4 @@ class SplunkMaskBodyInterceptor(
3637
3738
return intercepted
3839
}
39-
}
40+
}*/

integration/okhttp/src/main/java/com/splunk/rum/integration/okhttp/interceptor/SplunkNonBinaryBodyInterceptor.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import okio.Buffer
2525
import java.io.IOException
2626
import java.nio.charset.Charset
2727

28-
class SplunkNonBinaryBodyInterceptor : SplunkOkHttpInterceptor {
28+
// Not supported by a BE at the moment
29+
/*class SplunkNonBinaryBodyInterceptor : SplunkOkHttpInterceptor {
2930
3031
override fun onIntercept(original: SplunkChain, intercepted: SplunkNetworkRequest): SplunkNetworkRequest {
3132
intercepted.requestBody = original.request.parseBody()
@@ -94,4 +95,4 @@ class SplunkNonBinaryBodyInterceptor : SplunkOkHttpInterceptor {
9495
"text/x-markdown"
9596
)
9697
}
97-
}
98+
}*/

integration/okhttp/src/test/java/com/splunk/sdk/interception/okhttp/InterceptionManagerTest.kt

+41-42
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package com.splunk.sdk.interception.okhttp
1919
import com.splunk.rum.integration.agent.api.network.SplunkNetworkRequest
2020
import com.splunk.rum.integration.okhttp.InterceptionManager
2121
import com.splunk.rum.integration.okhttp.interceptor.SplunkHeadersInterceptor
22-
import com.splunk.rum.integration.okhttp.interceptor.SplunkMaskBodyInterceptor
22+
//import com.splunk.rum.integration.okhttp.interceptor.SplunkMaskBodyInterceptor
2323
import com.splunk.rum.integration.okhttp.interceptor.SplunkMaskUrlInterceptor
24-
import com.splunk.rum.integration.okhttp.interceptor.SplunkNonBinaryBodyInterceptor
24+
//import com.splunk.rum.integration.okhttp.interceptor.SplunkNonBinaryBodyInterceptor
2525
import com.splunk.rum.integration.okhttp.interceptor.SplunkOkHttpInterceptor
2626
import com.splunk.rum.integration.okhttp.listener.OkHttpConnectorListenerDummy
2727
import com.splunk.rum.integration.okhttp.model.Mask
@@ -98,7 +98,7 @@ class InterceptionManagerTest {
9898
whenSuccessfulCallExecuted(request, response)
9999

100100
thenStatusCodeIs(OK_STATUS_CODE)
101-
thenStatusIs(SplunkNetworkRequest.Status.OK)
101+
//thenStatusIs(SplunkNetworkRequest.Status.OK)
102102
thenInterceptedUrlIs(mockURL)
103103
thenInterceptedMethodIs(GET_METHOD)
104104
}
@@ -241,7 +241,7 @@ class InterceptionManagerTest {
241241
thenResponseDoesNotContainHeader("restricted")
242242
}
243243

244-
@Test
244+
/*@Test
245245
fun `json request and response body with default interceptor`() {
246246
val request = TestRequest(
247247
url = mockURL,
@@ -264,9 +264,9 @@ class InterceptionManagerTest {
264264
265265
thenRequestBodyIsNull()
266266
thenRequestBodyIsNull()
267-
}
267+
}*/
268268

269-
@Test
269+
/*@Test
270270
fun `json request and response body with NonBinaryBodyInterceptor interceptor`() {
271271
val request = TestRequest(
272272
url = mockURL,
@@ -289,9 +289,9 @@ class InterceptionManagerTest {
289289
290290
thenRequestBodyIs(JSONObject().put("request", "body").toString())
291291
thenResponseBodyIs(JSONObject().put("response", "body").toString())
292-
}
292+
}*/
293293

294-
@Test
294+
/*@Test
295295
fun `json request and response body masking with SplunkMaskBodyInterceptor`() {
296296
val request = TestRequest(
297297
url = mockURL,
@@ -335,11 +335,10 @@ class InterceptionManagerTest {
335335
thenResponseBodyDoesNotContain("simple_response")
336336
thenResponseBodyDoesNotContain("complex_response")
337337
thenResponseBodyContains("response_alternative")
338-
}
338+
}*/
339339

340340
@Test
341341
fun `failed request`() {
342-
343342
val request = TestRequest(
344343
url = mockURL,
345344
method = POST_METHOD,
@@ -353,8 +352,8 @@ class InterceptionManagerTest {
353352
whenFailedCallExecuted(request)
354353

355354
thenStatusCodeIs(UNKNOWN_STATUS_CODE)
356-
thenStatusIs(SplunkNetworkRequest.Status.ERROR)
357-
thenResponseBodyIs(null)
355+
//thenStatusIs(SplunkNetworkRequest.Status.ERROR)
356+
//thenResponseBodyIs(null)
358357
}
359358

360359
@Test
@@ -382,7 +381,7 @@ class InterceptionManagerTest {
382381
thenResponseContainsHeaderWithValue("not-allowed", "test")
383382
}
384383

385-
@Test
384+
/*@Test
386385
fun `binary response body`() {
387386
val request = TestRequest(
388387
url = mockURL,
@@ -404,9 +403,9 @@ class InterceptionManagerTest {
404403
whenSuccessfulCallExecuted(request, response)
405404
406405
thenResponseBodyIs(null)
407-
}
406+
}*/
408407

409-
@Test
408+
/*@Test
410409
fun `binary body with allow all content types interceptor`() {
411410
val responseBodyLength = 4096
412411
@@ -430,7 +429,7 @@ class InterceptionManagerTest {
430429
whenSuccessfulCallExecuted(request, response)
431430
432431
thenResponseBodyLengthIs(responseBodyLength)
433-
}
432+
}*/
434433

435434
/**
436435
* WARNING: Must be called before whenOkHttpBuilt().
@@ -444,21 +443,21 @@ class InterceptionManagerTest {
444443
whenInterceptorAdded(DefaultOkHttpInterceptor())
445444
}
446445

447-
private fun whenNonBinaryBodyInterceptorAdded() {
446+
/*private fun whenNonBinaryBodyInterceptorAdded() {
448447
whenInterceptorAdded(SplunkNonBinaryBodyInterceptor())
449-
}
448+
}*/
450449

451450
private fun whenAllowAllHeadersInterceptorAdded() {
452451
whenInterceptorAdded(AllowAllHeadersInterceptor())
453452
}
454453

455-
private fun whenAllowAllContentTypesInterceptorAdded() {
454+
/*private fun whenAllowAllContentTypesInterceptorAdded() {
456455
whenInterceptorAdded(AllowAllContentTypesInterceptor())
457-
}
456+
}*/
458457

459-
private fun whenSplunkMaskBodyInterceptor(masks: List<Mask>) {
458+
/*private fun whenSplunkMaskBodyInterceptor(masks: List<Mask>) {
460459
whenInterceptorAdded(SplunkMaskBodyInterceptor(masks))
461-
}
460+
}*/
462461

463462
private fun whenSplunkHeadersInterceptorAdded(allowedHeaders: Set<String>) {
464463
whenInterceptorAdded(SplunkHeadersInterceptor(allowedHeaders))
@@ -505,9 +504,9 @@ class InterceptionManagerTest {
505504
Assert.assertEquals(statusCode, sdkConnector.request?.statusCode)
506505
}
507506

508-
private fun thenStatusIs(status: SplunkNetworkRequest.Status) {
507+
/*private fun thenStatusIs(status: SplunkNetworkRequest.Status) {
509508
Assert.assertEquals(status, sdkConnector.request?.status)
510-
}
509+
}*/
511510

512511
private fun thenInterceptedMethodIs(method: String) {
513512
Assert.assertEquals(method, sdkConnector.request?.method)
@@ -517,37 +516,37 @@ class InterceptionManagerTest {
517516
Assert.assertEquals(mockURL, sdkConnector.request?.url)
518517
}
519518

520-
private fun thenRequestBodyIs(body: String?) {
519+
/*private fun thenRequestBodyIs(body: String?) {
521520
Assert.assertEquals(body, sdkConnector.request?.requestBody)
522-
}
521+
}*/
523522

524-
private fun thenResponseBodyIs(body: String?) {
523+
/*private fun thenResponseBodyIs(body: String?) {
525524
Assert.assertEquals(body, sdkConnector.request?.responseBody)
526-
}
525+
}*/
527526

528-
private fun thenRequestBodyIsNull() {
527+
/*private fun thenRequestBodyIsNull() {
529528
Assert.assertNull(sdkConnector.request?.requestBody)
530-
}
529+
}*/
531530

532-
private fun thenResponseBodyLengthIs(responseBodyLength: Int) {
531+
/*private fun thenResponseBodyLengthIs(responseBodyLength: Int) {
533532
Assert.assertEquals(responseBodyLength, sdkConnector.request?.responseBody?.length ?: -1)
534-
}
533+
}*/
535534

536-
private fun thenRequestBodyContains(contains: String) {
535+
/*private fun thenRequestBodyContains(contains: String) {
537536
Assert.assertTrue(sdkConnector.request?.requestBody?.contains(contains) == true)
538-
}
537+
}*/
539538

540-
private fun thenResponseBodyContains(contains: String) {
539+
/*private fun thenResponseBodyContains(contains: String) {
541540
Assert.assertTrue(sdkConnector.request?.responseBody?.contains(contains) == true)
542-
}
541+
}*/
543542

544-
private fun thenRequestBodyDoesNotContain(contains: String) {
543+
/*private fun thenRequestBodyDoesNotContain(contains: String) {
545544
Assert.assertFalse(sdkConnector.request?.requestBody?.contains(contains) == true)
546-
}
545+
}*/
547546

548-
private fun thenResponseBodyDoesNotContain(contains: String) {
547+
/*private fun thenResponseBodyDoesNotContain(contains: String) {
549548
Assert.assertFalse(sdkConnector.request?.responseBody?.contains(contains) == true)
550-
}
549+
}*/
551550

552551
private fun thenRequestContainsHeaderWithValue(key: String, value: String) {
553552
Assert.assertTrue(sdkConnector.request?.requestHeaders?.contains(key) == true)
@@ -641,13 +640,13 @@ class InterceptionManagerTest {
641640
}
642641
}
643642

644-
class AllowAllContentTypesInterceptor : SplunkOkHttpInterceptor {
643+
/*class AllowAllContentTypesInterceptor : SplunkOkHttpInterceptor {
645644
override fun onIntercept(original: SplunkChain, intercepted: SplunkNetworkRequest): SplunkNetworkRequest {
646645
intercepted.requestBody = Buffer().also { buffer -> original.request.body?.writeTo(buffer) }.readUtf8()
647646
intercepted.responseBody = original.response?.peekBody(1_000_000_000)?.string()
648647
return intercepted
649648
}
650-
}
649+
}*/
651650

652651
private companion object {
653652
const val UNKNOWN_STATUS_CODE = -1

0 commit comments

Comments
 (0)