@datadog/mobile-react-native 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DatadogSDKReactNative.podspec +2 -1
- package/android/build.gradle +73 -3
- package/android/gradle.properties +1 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
- package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
- package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
- package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
- package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
- package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
- package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
- package/ios/Sources/AnyEncodable.swift +138 -0
- package/ios/Sources/Attributes.swift +101 -0
- package/ios/Sources/DdLogs.swift +35 -11
- package/ios/Sources/DdRum.m +3 -1
- package/ios/Sources/DdRum.swift +184 -22
- package/ios/Sources/DdSdk.swift +190 -10
- package/ios/Sources/DdSdkConfiguration.swift +51 -0
- package/ios/Sources/DdTrace.swift +41 -6
- package/ios/Sources/GlobalState.swift +28 -0
- package/ios/Sources/QueueHolder.swift +10 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
- package/lib/commonjs/DdSdkReactNative.js +14 -0
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/foundation.js +36 -2
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js +36 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/types.js +26 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +14 -0
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/foundation.js +36 -2
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/nativeModulesTypes.js +26 -0
- package/lib/module/nativeModulesTypes.js.map +1 -0
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/types.js +23 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +2 -0
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
- package/lib/typescript/foundation.d.ts +3 -2
- package/lib/typescript/nativeModulesTypes.d.ts +168 -0
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +2 -1
- package/lib/typescript/types.d.ts +42 -7
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/DdSdkReactNative.tsx +20 -0
- package/src/DdSdkReactNativeConfiguration.tsx +20 -0
- package/src/__tests__/DdSdkReactNative.test.tsx +76 -0
- package/src/__tests__/foundation.test.ts +79 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +8 -8
- package/src/foundation.tsx +40 -11
- package/src/nativeModulesTypes.ts +258 -0
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
- package/src/types.tsx +62 -7
- package/src/version.ts +1 -1
- package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
- package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
- package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
|
@@ -0,0 +1,1547 @@
|
|
|
1
|
+
package com.datadog.reactnative
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import android.content.pm.PackageInfo
|
|
5
|
+
import com.datadog.android.DatadogEndpoint
|
|
6
|
+
import com.datadog.android.core.configuration.BatchSize
|
|
7
|
+
import com.datadog.android.core.configuration.Configuration
|
|
8
|
+
import com.datadog.android.core.configuration.Credentials
|
|
9
|
+
import com.datadog.android.core.configuration.UploadFrequency
|
|
10
|
+
import com.datadog.android.plugin.DatadogPlugin
|
|
11
|
+
import com.datadog.android.privacy.TrackingConsent
|
|
12
|
+
import com.datadog.android.rum.tracking.ActivityViewTrackingStrategy
|
|
13
|
+
import com.datadog.tools.unit.GenericAssert.Companion.assertThat
|
|
14
|
+
import com.datadog.tools.unit.forge.BaseConfigurator
|
|
15
|
+
import com.datadog.tools.unit.toReadableJavaOnlyMap
|
|
16
|
+
import com.datadog.tools.unit.toReadableMap
|
|
17
|
+
import com.facebook.react.bridge.Promise
|
|
18
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
|
+
import com.nhaarman.mockitokotlin2.any
|
|
20
|
+
import com.nhaarman.mockitokotlin2.argumentCaptor
|
|
21
|
+
import com.nhaarman.mockitokotlin2.doReturn
|
|
22
|
+
import com.nhaarman.mockitokotlin2.eq
|
|
23
|
+
import com.nhaarman.mockitokotlin2.inOrder
|
|
24
|
+
import com.nhaarman.mockitokotlin2.isNull
|
|
25
|
+
import com.nhaarman.mockitokotlin2.never
|
|
26
|
+
import com.nhaarman.mockitokotlin2.same
|
|
27
|
+
import com.nhaarman.mockitokotlin2.verify
|
|
28
|
+
import com.nhaarman.mockitokotlin2.whenever
|
|
29
|
+
import fr.xgouchet.elmyr.Forge
|
|
30
|
+
import fr.xgouchet.elmyr.annotation.AdvancedForgery
|
|
31
|
+
import fr.xgouchet.elmyr.annotation.Forgery
|
|
32
|
+
import fr.xgouchet.elmyr.annotation.IntForgery
|
|
33
|
+
import fr.xgouchet.elmyr.annotation.MapForgery
|
|
34
|
+
import fr.xgouchet.elmyr.annotation.StringForgery
|
|
35
|
+
import fr.xgouchet.elmyr.annotation.StringForgeryType
|
|
36
|
+
import fr.xgouchet.elmyr.junit5.ForgeConfiguration
|
|
37
|
+
import fr.xgouchet.elmyr.junit5.ForgeExtension
|
|
38
|
+
import java.net.InetSocketAddress
|
|
39
|
+
import java.net.Proxy
|
|
40
|
+
import java.util.Locale
|
|
41
|
+
import org.assertj.core.api.Assertions.assertThat
|
|
42
|
+
import org.junit.jupiter.api.AfterEach
|
|
43
|
+
import org.junit.jupiter.api.Assumptions.assumeTrue
|
|
44
|
+
import org.junit.jupiter.api.BeforeEach
|
|
45
|
+
import org.junit.jupiter.api.Test
|
|
46
|
+
import org.junit.jupiter.api.extension.ExtendWith
|
|
47
|
+
import org.junit.jupiter.api.extension.Extensions
|
|
48
|
+
import org.mockito.Mock
|
|
49
|
+
import org.mockito.Answers
|
|
50
|
+
import org.mockito.junit.jupiter.MockitoExtension
|
|
51
|
+
import org.mockito.junit.jupiter.MockitoSettings
|
|
52
|
+
import org.mockito.quality.Strictness
|
|
53
|
+
|
|
54
|
+
@Extensions(
|
|
55
|
+
ExtendWith(MockitoExtension::class),
|
|
56
|
+
ExtendWith(ForgeExtension::class)
|
|
57
|
+
)
|
|
58
|
+
@MockitoSettings(strictness = Strictness.LENIENT)
|
|
59
|
+
@ForgeConfiguration(BaseConfigurator::class)
|
|
60
|
+
internal class DdSdkTest {
|
|
61
|
+
|
|
62
|
+
lateinit var testedBridgeSdk: DdSdk
|
|
63
|
+
|
|
64
|
+
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
|
65
|
+
lateinit var mockContext: ReactApplicationContext
|
|
66
|
+
|
|
67
|
+
@Mock
|
|
68
|
+
lateinit var mockDatadog: DatadogWrapper
|
|
69
|
+
|
|
70
|
+
@Forgery
|
|
71
|
+
lateinit var fakeConfiguration: DdSdkConfiguration
|
|
72
|
+
|
|
73
|
+
@Mock
|
|
74
|
+
lateinit var mockPromise: Promise
|
|
75
|
+
|
|
76
|
+
@Forgery
|
|
77
|
+
lateinit var mockPackageInfo: PackageInfo
|
|
78
|
+
|
|
79
|
+
@BeforeEach
|
|
80
|
+
fun `set up`() {
|
|
81
|
+
whenever(mockContext.applicationContext) doReturn mockContext
|
|
82
|
+
whenever(mockContext.packageName) doReturn "packageName"
|
|
83
|
+
whenever(mockContext.packageManager.getPackageInfo("packageName", 0)) doReturn mockPackageInfo
|
|
84
|
+
testedBridgeSdk = DdSdk(mockContext, mockDatadog)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@AfterEach
|
|
88
|
+
fun `tear down`() {
|
|
89
|
+
GlobalState.globalAttributes.clear()
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// region initialize / nativeCrashReportEnabled
|
|
93
|
+
|
|
94
|
+
@Test
|
|
95
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {nativeCrashReportEnabled=true}`() {
|
|
96
|
+
// Given
|
|
97
|
+
val bridgeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = true)
|
|
98
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
99
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
100
|
+
|
|
101
|
+
// When
|
|
102
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
103
|
+
|
|
104
|
+
// Then
|
|
105
|
+
inOrder(mockDatadog) {
|
|
106
|
+
verify(mockDatadog).initialize(
|
|
107
|
+
same(mockContext),
|
|
108
|
+
credentialCaptor.capture(),
|
|
109
|
+
configCaptor.capture(),
|
|
110
|
+
any()
|
|
111
|
+
)
|
|
112
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
113
|
+
}
|
|
114
|
+
assertThat(configCaptor.firstValue)
|
|
115
|
+
.hasField("coreConfig") {
|
|
116
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
117
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
118
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
119
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
120
|
+
}
|
|
121
|
+
.hasField("logsConfig") {
|
|
122
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
123
|
+
}
|
|
124
|
+
.hasField("tracesConfig") {
|
|
125
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
126
|
+
}
|
|
127
|
+
.hasField("crashReportConfig") {
|
|
128
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
129
|
+
}
|
|
130
|
+
.hasField("rumConfig") {
|
|
131
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
132
|
+
}
|
|
133
|
+
.hasFieldEqualTo(
|
|
134
|
+
"additionalConfig",
|
|
135
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
136
|
+
)
|
|
137
|
+
val credentials = credentialCaptor.firstValue
|
|
138
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
139
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
140
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
141
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@Test
|
|
145
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {nativeCrashReportEnabled=false}`() {
|
|
146
|
+
// Given
|
|
147
|
+
fakeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = false, site = null)
|
|
148
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
149
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
150
|
+
|
|
151
|
+
// When
|
|
152
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
153
|
+
|
|
154
|
+
// Then
|
|
155
|
+
inOrder(mockDatadog) {
|
|
156
|
+
verify(mockDatadog).initialize(
|
|
157
|
+
same(mockContext),
|
|
158
|
+
credentialCaptor.capture(),
|
|
159
|
+
configCaptor.capture(),
|
|
160
|
+
any()
|
|
161
|
+
)
|
|
162
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
163
|
+
}
|
|
164
|
+
assertThat(configCaptor.firstValue)
|
|
165
|
+
.hasField("coreConfig") {
|
|
166
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
167
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
168
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
169
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
170
|
+
}
|
|
171
|
+
.hasField("logsConfig") {
|
|
172
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
173
|
+
}
|
|
174
|
+
.hasField("tracesConfig") {
|
|
175
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
176
|
+
}
|
|
177
|
+
.hasFieldEqualTo("crashReportConfig", null)
|
|
178
|
+
.hasField("rumConfig") {
|
|
179
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
180
|
+
}
|
|
181
|
+
.hasFieldEqualTo(
|
|
182
|
+
"additionalConfig",
|
|
183
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
184
|
+
)
|
|
185
|
+
val credentials = credentialCaptor.firstValue
|
|
186
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
187
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
188
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
189
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@Test
|
|
193
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {nativeCrashReportEnabled=null}`() {
|
|
194
|
+
// Given
|
|
195
|
+
fakeConfiguration = fakeConfiguration.copy(nativeCrashReportEnabled = false, site = null)
|
|
196
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
197
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
198
|
+
|
|
199
|
+
// When
|
|
200
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
201
|
+
|
|
202
|
+
// Then
|
|
203
|
+
inOrder(mockDatadog) {
|
|
204
|
+
verify(mockDatadog).initialize(
|
|
205
|
+
same(mockContext),
|
|
206
|
+
credentialCaptor.capture(),
|
|
207
|
+
configCaptor.capture(),
|
|
208
|
+
any()
|
|
209
|
+
)
|
|
210
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
211
|
+
}
|
|
212
|
+
assertThat(configCaptor.firstValue)
|
|
213
|
+
.hasField("coreConfig") {
|
|
214
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
215
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
216
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
217
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
218
|
+
}
|
|
219
|
+
.hasField("logsConfig") {
|
|
220
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
221
|
+
}
|
|
222
|
+
.hasField("tracesConfig") {
|
|
223
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
224
|
+
}
|
|
225
|
+
.hasFieldEqualTo("crashReportConfig", null)
|
|
226
|
+
.hasField("rumConfig") {
|
|
227
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
228
|
+
}
|
|
229
|
+
.hasFieldEqualTo(
|
|
230
|
+
"additionalConfig",
|
|
231
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
232
|
+
)
|
|
233
|
+
val credentials = credentialCaptor.firstValue
|
|
234
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
235
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
236
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
237
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// endregion
|
|
241
|
+
|
|
242
|
+
// region initialize / sampleRate
|
|
243
|
+
|
|
244
|
+
@Test
|
|
245
|
+
fun `𝕄 initialize native with sample rate SDK 𝕎 initialize() {}`() {
|
|
246
|
+
// Given
|
|
247
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
248
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
249
|
+
val expectedRumSampleRate = fakeConfiguration.sampleRate?.toFloat() ?: 100f
|
|
250
|
+
|
|
251
|
+
// When
|
|
252
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
253
|
+
|
|
254
|
+
// Then
|
|
255
|
+
inOrder(mockDatadog) {
|
|
256
|
+
verify(mockDatadog).initialize(
|
|
257
|
+
same(mockContext),
|
|
258
|
+
credentialCaptor.capture(),
|
|
259
|
+
configCaptor.capture(),
|
|
260
|
+
any()
|
|
261
|
+
)
|
|
262
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
263
|
+
}
|
|
264
|
+
assertThat(configCaptor.firstValue)
|
|
265
|
+
.hasField("coreConfig") {
|
|
266
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
267
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
268
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
269
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
270
|
+
}
|
|
271
|
+
.hasField("logsConfig") {
|
|
272
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
273
|
+
}
|
|
274
|
+
.hasField("tracesConfig") {
|
|
275
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
276
|
+
}
|
|
277
|
+
.hasField("rumConfig") {
|
|
278
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
279
|
+
it.hasFieldEqualTo("samplingRate", expectedRumSampleRate)
|
|
280
|
+
}
|
|
281
|
+
.hasFieldEqualTo(
|
|
282
|
+
"additionalConfig",
|
|
283
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
284
|
+
)
|
|
285
|
+
val credentials = credentialCaptor.firstValue
|
|
286
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
287
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
288
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
289
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// endregion
|
|
293
|
+
|
|
294
|
+
// region initialize / additionalConfig
|
|
295
|
+
|
|
296
|
+
@Test
|
|
297
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {additionalConfig=null}`() {
|
|
298
|
+
// Given
|
|
299
|
+
fakeConfiguration = fakeConfiguration.copy(additionalConfig = null)
|
|
300
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
301
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
302
|
+
|
|
303
|
+
// When
|
|
304
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
305
|
+
|
|
306
|
+
// Then
|
|
307
|
+
inOrder(mockDatadog) {
|
|
308
|
+
verify(mockDatadog).initialize(
|
|
309
|
+
same(mockContext),
|
|
310
|
+
credentialCaptor.capture(),
|
|
311
|
+
configCaptor.capture(),
|
|
312
|
+
any()
|
|
313
|
+
)
|
|
314
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
315
|
+
}
|
|
316
|
+
assertThat(configCaptor.firstValue)
|
|
317
|
+
.hasField("coreConfig") {
|
|
318
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
319
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
320
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
321
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
322
|
+
}
|
|
323
|
+
.hasField("logsConfig") {
|
|
324
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
325
|
+
}
|
|
326
|
+
.hasField("tracesConfig") {
|
|
327
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
328
|
+
}
|
|
329
|
+
.hasField("rumConfig") {
|
|
330
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
331
|
+
}
|
|
332
|
+
.hasFieldEqualTo("additionalConfig", emptyMap<String, Any?>())
|
|
333
|
+
val credentials = credentialCaptor.firstValue
|
|
334
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
335
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
336
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
337
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@Test
|
|
341
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {additionalConfig=nonNull}`() {
|
|
342
|
+
// Given
|
|
343
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
344
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
345
|
+
|
|
346
|
+
// When
|
|
347
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
348
|
+
|
|
349
|
+
// Then
|
|
350
|
+
inOrder(mockDatadog) {
|
|
351
|
+
verify(mockDatadog).initialize(
|
|
352
|
+
same(mockContext),
|
|
353
|
+
credentialCaptor.capture(),
|
|
354
|
+
configCaptor.capture(),
|
|
355
|
+
any()
|
|
356
|
+
)
|
|
357
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
358
|
+
}
|
|
359
|
+
assertThat(configCaptor.firstValue)
|
|
360
|
+
.hasField("coreConfig") {
|
|
361
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
362
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
363
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
364
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
365
|
+
}
|
|
366
|
+
.hasField("logsConfig") {
|
|
367
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
368
|
+
}
|
|
369
|
+
.hasField("tracesConfig") {
|
|
370
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
371
|
+
}
|
|
372
|
+
.hasField("rumConfig") {
|
|
373
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
374
|
+
}
|
|
375
|
+
.hasFieldEqualTo(
|
|
376
|
+
"additionalConfig",
|
|
377
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
378
|
+
)
|
|
379
|
+
val credentials = credentialCaptor.firstValue
|
|
380
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
381
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
382
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
383
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// endregion
|
|
387
|
+
|
|
388
|
+
// region initialize / site
|
|
389
|
+
|
|
390
|
+
@Test
|
|
391
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=null}`(
|
|
392
|
+
forge: Forge
|
|
393
|
+
) {
|
|
394
|
+
// Given
|
|
395
|
+
fakeConfiguration = fakeConfiguration.copy(site = null, nativeCrashReportEnabled = true)
|
|
396
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
397
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
398
|
+
|
|
399
|
+
// When
|
|
400
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
401
|
+
|
|
402
|
+
// Then
|
|
403
|
+
inOrder(mockDatadog) {
|
|
404
|
+
verify(mockDatadog).initialize(
|
|
405
|
+
same(mockContext),
|
|
406
|
+
credentialCaptor.capture(),
|
|
407
|
+
configCaptor.capture(),
|
|
408
|
+
any()
|
|
409
|
+
)
|
|
410
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
411
|
+
}
|
|
412
|
+
assertThat(configCaptor.firstValue)
|
|
413
|
+
.hasField("coreConfig") {
|
|
414
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
415
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
416
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
417
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
418
|
+
}
|
|
419
|
+
.hasField("logsConfig") {
|
|
420
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1)
|
|
421
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
422
|
+
}
|
|
423
|
+
.hasField("tracesConfig") {
|
|
424
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_US1)
|
|
425
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
426
|
+
}
|
|
427
|
+
.hasField("rumConfig") {
|
|
428
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_US1)
|
|
429
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
430
|
+
}
|
|
431
|
+
.hasField("crashReportConfig") {
|
|
432
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1)
|
|
433
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
434
|
+
}
|
|
435
|
+
.hasFieldEqualTo(
|
|
436
|
+
"additionalConfig",
|
|
437
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
438
|
+
)
|
|
439
|
+
val credentials = credentialCaptor.firstValue
|
|
440
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
441
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
442
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
443
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
@Test
|
|
447
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=us1}`(
|
|
448
|
+
forge: Forge
|
|
449
|
+
) {
|
|
450
|
+
// Given
|
|
451
|
+
val site = forge.randomizeCase("us1")
|
|
452
|
+
fakeConfiguration = fakeConfiguration.copy(site = site, nativeCrashReportEnabled = true)
|
|
453
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
454
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
455
|
+
|
|
456
|
+
// When
|
|
457
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
458
|
+
|
|
459
|
+
// Then
|
|
460
|
+
inOrder(mockDatadog) {
|
|
461
|
+
verify(mockDatadog).initialize(
|
|
462
|
+
same(mockContext),
|
|
463
|
+
credentialCaptor.capture(),
|
|
464
|
+
configCaptor.capture(),
|
|
465
|
+
any()
|
|
466
|
+
)
|
|
467
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
468
|
+
}
|
|
469
|
+
assertThat(configCaptor.firstValue)
|
|
470
|
+
.hasField("coreConfig") {
|
|
471
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
472
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
473
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
474
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
475
|
+
}
|
|
476
|
+
.hasField("logsConfig") {
|
|
477
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1)
|
|
478
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
479
|
+
}
|
|
480
|
+
.hasField("tracesConfig") {
|
|
481
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_US1)
|
|
482
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
483
|
+
}
|
|
484
|
+
.hasField("rumConfig") {
|
|
485
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_US1)
|
|
486
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
487
|
+
}
|
|
488
|
+
.hasField("crashReportConfig") {
|
|
489
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1)
|
|
490
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
491
|
+
}
|
|
492
|
+
.hasFieldEqualTo(
|
|
493
|
+
"additionalConfig",
|
|
494
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
495
|
+
)
|
|
496
|
+
val credentials = credentialCaptor.firstValue
|
|
497
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
498
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
499
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
500
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@Test
|
|
504
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=us3}`(
|
|
505
|
+
forge: Forge
|
|
506
|
+
) {
|
|
507
|
+
// Given
|
|
508
|
+
val site = forge.randomizeCase("us3")
|
|
509
|
+
fakeConfiguration = fakeConfiguration.copy(site = site, nativeCrashReportEnabled = true)
|
|
510
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
511
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
512
|
+
|
|
513
|
+
// When
|
|
514
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
515
|
+
|
|
516
|
+
// Then
|
|
517
|
+
inOrder(mockDatadog) {
|
|
518
|
+
verify(mockDatadog).initialize(
|
|
519
|
+
same(mockContext),
|
|
520
|
+
credentialCaptor.capture(),
|
|
521
|
+
configCaptor.capture(),
|
|
522
|
+
any()
|
|
523
|
+
)
|
|
524
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
525
|
+
}
|
|
526
|
+
assertThat(configCaptor.firstValue)
|
|
527
|
+
.hasField("coreConfig") {
|
|
528
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
529
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
530
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
531
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
532
|
+
}
|
|
533
|
+
.hasField("logsConfig") {
|
|
534
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US3)
|
|
535
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
536
|
+
}
|
|
537
|
+
.hasField("tracesConfig") {
|
|
538
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_US3)
|
|
539
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
540
|
+
}
|
|
541
|
+
.hasField("rumConfig") {
|
|
542
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_US3)
|
|
543
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
544
|
+
}
|
|
545
|
+
.hasField("crashReportConfig") {
|
|
546
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US3)
|
|
547
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
548
|
+
}
|
|
549
|
+
.hasFieldEqualTo(
|
|
550
|
+
"additionalConfig",
|
|
551
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
552
|
+
)
|
|
553
|
+
val credentials = credentialCaptor.firstValue
|
|
554
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
555
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
556
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
557
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
@Test
|
|
561
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=us5}`(
|
|
562
|
+
forge: Forge
|
|
563
|
+
) {
|
|
564
|
+
// Given
|
|
565
|
+
val site = forge.randomizeCase("us5")
|
|
566
|
+
fakeConfiguration = fakeConfiguration.copy(site = site, nativeCrashReportEnabled = true)
|
|
567
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
568
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
569
|
+
|
|
570
|
+
// When
|
|
571
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
572
|
+
|
|
573
|
+
// Then
|
|
574
|
+
inOrder(mockDatadog) {
|
|
575
|
+
verify(mockDatadog).initialize(
|
|
576
|
+
same(mockContext),
|
|
577
|
+
credentialCaptor.capture(),
|
|
578
|
+
configCaptor.capture(),
|
|
579
|
+
any()
|
|
580
|
+
)
|
|
581
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
582
|
+
}
|
|
583
|
+
assertThat(configCaptor.firstValue)
|
|
584
|
+
.hasField("coreConfig") {
|
|
585
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
586
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
587
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
588
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
589
|
+
}
|
|
590
|
+
.hasField("logsConfig") {
|
|
591
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US5)
|
|
592
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
593
|
+
}
|
|
594
|
+
.hasField("tracesConfig") {
|
|
595
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_US5)
|
|
596
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
597
|
+
}
|
|
598
|
+
.hasField("rumConfig") {
|
|
599
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_US5)
|
|
600
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
601
|
+
}
|
|
602
|
+
.hasField("crashReportConfig") {
|
|
603
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US5)
|
|
604
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
605
|
+
}
|
|
606
|
+
.hasFieldEqualTo(
|
|
607
|
+
"additionalConfig",
|
|
608
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
609
|
+
)
|
|
610
|
+
val credentials = credentialCaptor.firstValue
|
|
611
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
612
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
613
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
614
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
@Test
|
|
618
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=us1_fed}`(
|
|
619
|
+
forge: Forge
|
|
620
|
+
) {
|
|
621
|
+
// Given
|
|
622
|
+
val site = forge.randomizeCase("us1_fed")
|
|
623
|
+
fakeConfiguration = fakeConfiguration.copy(site = site, nativeCrashReportEnabled = true)
|
|
624
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
625
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
626
|
+
|
|
627
|
+
// When
|
|
628
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
629
|
+
|
|
630
|
+
// Then
|
|
631
|
+
inOrder(mockDatadog) {
|
|
632
|
+
verify(mockDatadog).initialize(
|
|
633
|
+
same(mockContext),
|
|
634
|
+
credentialCaptor.capture(),
|
|
635
|
+
configCaptor.capture(),
|
|
636
|
+
any()
|
|
637
|
+
)
|
|
638
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
639
|
+
}
|
|
640
|
+
assertThat(configCaptor.firstValue)
|
|
641
|
+
.hasField("coreConfig") {
|
|
642
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
643
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
644
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
645
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
646
|
+
}
|
|
647
|
+
.hasField("logsConfig") {
|
|
648
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1_FED)
|
|
649
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
650
|
+
}
|
|
651
|
+
.hasField("tracesConfig") {
|
|
652
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_US1_FED)
|
|
653
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
654
|
+
}
|
|
655
|
+
.hasField("rumConfig") {
|
|
656
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_US1_FED)
|
|
657
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
658
|
+
}
|
|
659
|
+
.hasField("crashReportConfig") {
|
|
660
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_US1_FED)
|
|
661
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
662
|
+
}
|
|
663
|
+
.hasFieldEqualTo(
|
|
664
|
+
"additionalConfig",
|
|
665
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
666
|
+
)
|
|
667
|
+
val credentials = credentialCaptor.firstValue
|
|
668
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
669
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
670
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
671
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
@Test
|
|
675
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {site=eu1}`(
|
|
676
|
+
forge: Forge
|
|
677
|
+
) {
|
|
678
|
+
// Given
|
|
679
|
+
val site = forge.randomizeCase("eu1")
|
|
680
|
+
fakeConfiguration = fakeConfiguration.copy(site = site, nativeCrashReportEnabled = true)
|
|
681
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
682
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
683
|
+
|
|
684
|
+
// When
|
|
685
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
686
|
+
|
|
687
|
+
// Then
|
|
688
|
+
inOrder(mockDatadog) {
|
|
689
|
+
verify(mockDatadog).initialize(
|
|
690
|
+
same(mockContext),
|
|
691
|
+
credentialCaptor.capture(),
|
|
692
|
+
configCaptor.capture(),
|
|
693
|
+
any()
|
|
694
|
+
)
|
|
695
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
696
|
+
}
|
|
697
|
+
assertThat(configCaptor.firstValue)
|
|
698
|
+
.hasField("coreConfig") {
|
|
699
|
+
it.hasFieldEqualTo("needsClearTextHttp", false)
|
|
700
|
+
it.hasFieldEqualTo("firstPartyHosts", emptyList<String>())
|
|
701
|
+
it.hasFieldEqualTo("batchSize", BatchSize.MEDIUM)
|
|
702
|
+
it.hasFieldEqualTo("uploadFrequency", UploadFrequency.AVERAGE)
|
|
703
|
+
}
|
|
704
|
+
.hasField("logsConfig") {
|
|
705
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_EU1)
|
|
706
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
707
|
+
}
|
|
708
|
+
.hasField("tracesConfig") {
|
|
709
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.TRACES_EU1)
|
|
710
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
711
|
+
}
|
|
712
|
+
.hasField("rumConfig") {
|
|
713
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.RUM_EU1)
|
|
714
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
715
|
+
}
|
|
716
|
+
.hasField("crashReportConfig") {
|
|
717
|
+
it.hasFieldEqualTo("endpointUrl", DatadogEndpoint.LOGS_EU1)
|
|
718
|
+
it.hasFieldEqualTo("plugins", emptyList<DatadogPlugin>())
|
|
719
|
+
}
|
|
720
|
+
.hasFieldEqualTo(
|
|
721
|
+
"additionalConfig",
|
|
722
|
+
fakeConfiguration.additionalConfig?.filterValues { it != null }.orEmpty()
|
|
723
|
+
)
|
|
724
|
+
val credentials = credentialCaptor.firstValue
|
|
725
|
+
assertThat(credentials.clientToken).isEqualTo(fakeConfiguration.clientToken)
|
|
726
|
+
assertThat(credentials.envName).isEqualTo(fakeConfiguration.env)
|
|
727
|
+
assertThat(credentials.rumApplicationId).isEqualTo(fakeConfiguration.applicationId)
|
|
728
|
+
assertThat(credentials.variant).isEqualTo("")
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// endregion
|
|
732
|
+
|
|
733
|
+
// region initialize / additionalConfig
|
|
734
|
+
|
|
735
|
+
@Test
|
|
736
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {trackingConsent=null}`() {
|
|
737
|
+
// Given
|
|
738
|
+
fakeConfiguration = fakeConfiguration.copy(trackingConsent = null)
|
|
739
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
740
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
741
|
+
|
|
742
|
+
// When
|
|
743
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
744
|
+
|
|
745
|
+
// Then
|
|
746
|
+
inOrder(mockDatadog) {
|
|
747
|
+
verify(mockDatadog).initialize(
|
|
748
|
+
same(mockContext),
|
|
749
|
+
credentialCaptor.capture(),
|
|
750
|
+
configCaptor.capture(),
|
|
751
|
+
eq(TrackingConsent.PENDING)
|
|
752
|
+
)
|
|
753
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
@Test
|
|
758
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {trackingConsent=PENDING}`(
|
|
759
|
+
forge: Forge
|
|
760
|
+
) {
|
|
761
|
+
// Given
|
|
762
|
+
val consent = forge.randomizeCase("PENDING")
|
|
763
|
+
fakeConfiguration = fakeConfiguration.copy(trackingConsent = consent)
|
|
764
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
765
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
766
|
+
|
|
767
|
+
// When
|
|
768
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
769
|
+
|
|
770
|
+
// Then
|
|
771
|
+
inOrder(mockDatadog) {
|
|
772
|
+
verify(mockDatadog).initialize(
|
|
773
|
+
same(mockContext),
|
|
774
|
+
credentialCaptor.capture(),
|
|
775
|
+
configCaptor.capture(),
|
|
776
|
+
eq(TrackingConsent.PENDING)
|
|
777
|
+
)
|
|
778
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
@Test
|
|
783
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {trackingConsent=GRANTED}`(
|
|
784
|
+
forge: Forge
|
|
785
|
+
) {
|
|
786
|
+
// Given
|
|
787
|
+
val consent = forge.randomizeCase("GRANTED")
|
|
788
|
+
fakeConfiguration = fakeConfiguration.copy(trackingConsent = consent)
|
|
789
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
790
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
791
|
+
|
|
792
|
+
// When
|
|
793
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
794
|
+
|
|
795
|
+
// Then
|
|
796
|
+
inOrder(mockDatadog) {
|
|
797
|
+
verify(mockDatadog).initialize(
|
|
798
|
+
same(mockContext),
|
|
799
|
+
credentialCaptor.capture(),
|
|
800
|
+
configCaptor.capture(),
|
|
801
|
+
eq(TrackingConsent.GRANTED)
|
|
802
|
+
)
|
|
803
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
@Test
|
|
808
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {trackingConsent=NOT_GRANTED}`(
|
|
809
|
+
forge: Forge
|
|
810
|
+
) {
|
|
811
|
+
// Given
|
|
812
|
+
val consent = forge.randomizeCase("NOT_GRANTED")
|
|
813
|
+
fakeConfiguration = fakeConfiguration.copy(trackingConsent = consent)
|
|
814
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
815
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
816
|
+
|
|
817
|
+
// When
|
|
818
|
+
testedBridgeSdk.initialize(fakeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
819
|
+
|
|
820
|
+
// Then
|
|
821
|
+
inOrder(mockDatadog) {
|
|
822
|
+
verify(mockDatadog).initialize(
|
|
823
|
+
same(mockContext),
|
|
824
|
+
credentialCaptor.capture(),
|
|
825
|
+
configCaptor.capture(),
|
|
826
|
+
eq(TrackingConsent.NOT_GRANTED)
|
|
827
|
+
)
|
|
828
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// endregion
|
|
833
|
+
|
|
834
|
+
@Test
|
|
835
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {no view tracking by default}`(
|
|
836
|
+
@Forgery configuration: DdSdkConfiguration
|
|
837
|
+
) {
|
|
838
|
+
// Given
|
|
839
|
+
val bridgeConfiguration = configuration.copy(additionalConfig = null)
|
|
840
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
841
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
842
|
+
|
|
843
|
+
// When
|
|
844
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
845
|
+
|
|
846
|
+
// Then
|
|
847
|
+
inOrder(mockDatadog) {
|
|
848
|
+
verify(mockDatadog).initialize(
|
|
849
|
+
same(mockContext),
|
|
850
|
+
credentialCaptor.capture(),
|
|
851
|
+
configCaptor.capture(),
|
|
852
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
853
|
+
)
|
|
854
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
855
|
+
}
|
|
856
|
+
assertThat(configCaptor.firstValue)
|
|
857
|
+
.hasField("rumConfig") {
|
|
858
|
+
it.hasFieldEqualTo("viewTrackingStrategy", NoOpViewTrackingStrategy)
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
@Test
|
|
863
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {no view tracking}`(
|
|
864
|
+
@Forgery configuration: DdSdkConfiguration
|
|
865
|
+
) {
|
|
866
|
+
// Given
|
|
867
|
+
val bridgeConfiguration = configuration.copy(
|
|
868
|
+
additionalConfig = mapOf(
|
|
869
|
+
DdSdk.DD_NATIVE_VIEW_TRACKING to false
|
|
870
|
+
)
|
|
871
|
+
)
|
|
872
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
873
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
874
|
+
|
|
875
|
+
// When
|
|
876
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
877
|
+
|
|
878
|
+
// Then
|
|
879
|
+
inOrder(mockDatadog) {
|
|
880
|
+
verify(mockDatadog).initialize(
|
|
881
|
+
same(mockContext),
|
|
882
|
+
credentialCaptor.capture(),
|
|
883
|
+
configCaptor.capture(),
|
|
884
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
885
|
+
)
|
|
886
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
887
|
+
}
|
|
888
|
+
assertThat(configCaptor.firstValue)
|
|
889
|
+
.hasField("rumConfig") {
|
|
890
|
+
it.hasFieldEqualTo("viewTrackingStrategy", NoOpViewTrackingStrategy)
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
@Test
|
|
895
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {with view tracking}`(
|
|
896
|
+
@Forgery configuration: DdSdkConfiguration
|
|
897
|
+
) {
|
|
898
|
+
// Given
|
|
899
|
+
val bridgeConfiguration = configuration.copy(
|
|
900
|
+
additionalConfig = mapOf(
|
|
901
|
+
DdSdk.DD_NATIVE_VIEW_TRACKING to true
|
|
902
|
+
)
|
|
903
|
+
)
|
|
904
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
905
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
906
|
+
|
|
907
|
+
// When
|
|
908
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
909
|
+
|
|
910
|
+
// Then
|
|
911
|
+
inOrder(mockDatadog) {
|
|
912
|
+
verify(mockDatadog).initialize(
|
|
913
|
+
same(mockContext),
|
|
914
|
+
credentialCaptor.capture(),
|
|
915
|
+
configCaptor.capture(),
|
|
916
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
917
|
+
)
|
|
918
|
+
verify(mockDatadog).registerRumMonitor(any())
|
|
919
|
+
}
|
|
920
|
+
assertThat(configCaptor.firstValue)
|
|
921
|
+
.hasField("rumConfig") {
|
|
922
|
+
it.hasFieldEqualTo("viewTrackingStrategy", ActivityViewTrackingStrategy(false))
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
@Test
|
|
927
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {sdk verbosity}`(
|
|
928
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
929
|
+
@IntForgery(Log.DEBUG, Log.ASSERT) verbosity: Int
|
|
930
|
+
) {
|
|
931
|
+
// Given
|
|
932
|
+
val verbosityName = when (verbosity) {
|
|
933
|
+
Log.DEBUG -> "debug"
|
|
934
|
+
Log.INFO -> "info"
|
|
935
|
+
Log.WARN -> "warn"
|
|
936
|
+
Log.ERROR -> "error"
|
|
937
|
+
else -> ""
|
|
938
|
+
}
|
|
939
|
+
val bridgeConfiguration = configuration.copy(
|
|
940
|
+
additionalConfig = mapOf(
|
|
941
|
+
DdSdk.DD_SDK_VERBOSITY to verbosityName
|
|
942
|
+
)
|
|
943
|
+
)
|
|
944
|
+
|
|
945
|
+
// When
|
|
946
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
947
|
+
|
|
948
|
+
// Then
|
|
949
|
+
verify(mockDatadog).setVerbosity(verbosity)
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
@Test
|
|
953
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {invalid sdk verbosity}`(
|
|
954
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
955
|
+
@StringForgery(StringForgeryType.HEXADECIMAL) verbosity: String
|
|
956
|
+
) {
|
|
957
|
+
// Given
|
|
958
|
+
val bridgeConfiguration = configuration.copy(
|
|
959
|
+
additionalConfig = mapOf(
|
|
960
|
+
DdSdk.DD_SDK_VERBOSITY to verbosity
|
|
961
|
+
)
|
|
962
|
+
)
|
|
963
|
+
|
|
964
|
+
// When
|
|
965
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
966
|
+
|
|
967
|
+
// Then
|
|
968
|
+
verify(mockDatadog, never()).setVerbosity(any())
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
@Test
|
|
972
|
+
fun `𝕄 initialize native SDK 𝕎 initialize() {custom service name}`(
|
|
973
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
974
|
+
@StringForgery serviceName: String
|
|
975
|
+
) {
|
|
976
|
+
// Given
|
|
977
|
+
val bridgeConfiguration = configuration.copy(
|
|
978
|
+
additionalConfig = mapOf(
|
|
979
|
+
DdSdk.DD_SERVICE_NAME to serviceName
|
|
980
|
+
)
|
|
981
|
+
)
|
|
982
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
983
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
984
|
+
|
|
985
|
+
// When
|
|
986
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
987
|
+
|
|
988
|
+
// Then
|
|
989
|
+
verify(mockDatadog).initialize(
|
|
990
|
+
same(mockContext),
|
|
991
|
+
credentialCaptor.capture(),
|
|
992
|
+
configCaptor.capture(),
|
|
993
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
994
|
+
)
|
|
995
|
+
assertThat(credentialCaptor.firstValue.serviceName).isEqualTo(serviceName)
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
@Test
|
|
999
|
+
fun `𝕄 set long task threshold 𝕎 initialize() {custom long task threshold}`(
|
|
1000
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1001
|
+
forge: Forge
|
|
1002
|
+
) {
|
|
1003
|
+
// floating-point type (coming from JS) and integer type (other frameworks)
|
|
1004
|
+
val threshold = forge.anElementFrom(
|
|
1005
|
+
forge.aLong(min = 0, max = 65536),
|
|
1006
|
+
forge.aDouble(min = 0.0, max = 65536.0)
|
|
1007
|
+
)
|
|
1008
|
+
|
|
1009
|
+
// Given
|
|
1010
|
+
val bridgeConfiguration = configuration.copy(
|
|
1011
|
+
additionalConfig = mapOf(
|
|
1012
|
+
DdSdk.DD_LONG_TASK_THRESHOLD to threshold
|
|
1013
|
+
)
|
|
1014
|
+
)
|
|
1015
|
+
val credentialCaptor = argumentCaptor<Credentials>()
|
|
1016
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
1017
|
+
|
|
1018
|
+
// When
|
|
1019
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1020
|
+
|
|
1021
|
+
// Then
|
|
1022
|
+
verify(mockDatadog).initialize(
|
|
1023
|
+
same(mockContext),
|
|
1024
|
+
credentialCaptor.capture(),
|
|
1025
|
+
configCaptor.capture(),
|
|
1026
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
1027
|
+
)
|
|
1028
|
+
assertThat(configCaptor.firstValue)
|
|
1029
|
+
.hasField("rumConfig") { rumConfig ->
|
|
1030
|
+
rumConfig.hasField("longTaskTrackingStrategy") { longTaskTrackingStrategy ->
|
|
1031
|
+
longTaskTrackingStrategy
|
|
1032
|
+
.isInstanceOf(
|
|
1033
|
+
"com.datadog.android.rum.internal.instrumentation." +
|
|
1034
|
+
"MainLooperLongTaskStrategy"
|
|
1035
|
+
)
|
|
1036
|
+
.hasFieldEqualTo("thresholdMs", threshold.toLong())
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
@Test
|
|
1042
|
+
fun `𝕄 set first party hosts 𝕎 initialize() {first party hosts}`(
|
|
1043
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1044
|
+
forge: Forge
|
|
1045
|
+
) {
|
|
1046
|
+
val firstPartyHosts = forge.aList { forge.aStringMatching("[a-z]+\\.[a-z]{3}") }
|
|
1047
|
+
|
|
1048
|
+
// Given
|
|
1049
|
+
val bridgeConfiguration = configuration.copy(
|
|
1050
|
+
additionalConfig = mapOf(
|
|
1051
|
+
DdSdk.DD_FIRST_PARTY_HOSTS to firstPartyHosts
|
|
1052
|
+
)
|
|
1053
|
+
)
|
|
1054
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
1055
|
+
|
|
1056
|
+
// When
|
|
1057
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1058
|
+
|
|
1059
|
+
// Then
|
|
1060
|
+
verify(mockDatadog).initialize(
|
|
1061
|
+
same(mockContext),
|
|
1062
|
+
any(),
|
|
1063
|
+
configCaptor.capture(),
|
|
1064
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
1065
|
+
)
|
|
1066
|
+
assertThat(configCaptor.firstValue)
|
|
1067
|
+
.hasField("coreConfig") { coreConfig ->
|
|
1068
|
+
coreConfig.hasFieldEqualTo("firstPartyHosts", firstPartyHosts)
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// endregion
|
|
1073
|
+
|
|
1074
|
+
// region version suffix
|
|
1075
|
+
|
|
1076
|
+
@Test
|
|
1077
|
+
fun `𝕄 set version 𝕎 initialize() {versionSuffix}`(
|
|
1078
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1079
|
+
@StringForgery versionSuffix: String
|
|
1080
|
+
) {
|
|
1081
|
+
// Given
|
|
1082
|
+
val bridgeConfiguration = configuration.copy(
|
|
1083
|
+
additionalConfig = mapOf(
|
|
1084
|
+
DdSdk.DD_VERSION_SUFFIX to versionSuffix
|
|
1085
|
+
)
|
|
1086
|
+
)
|
|
1087
|
+
val configCaptor = argumentCaptor<Configuration>()
|
|
1088
|
+
|
|
1089
|
+
// When
|
|
1090
|
+
testedBridgeSdk.initialize(bridgeConfiguration.toReadableJavaOnlyMap(), mockPromise)
|
|
1091
|
+
|
|
1092
|
+
// Then
|
|
1093
|
+
verify(mockDatadog).initialize(
|
|
1094
|
+
same(mockContext),
|
|
1095
|
+
any(),
|
|
1096
|
+
configCaptor.capture(),
|
|
1097
|
+
eq(configuration.trackingConsent.asTrackingConsent())
|
|
1098
|
+
)
|
|
1099
|
+
assertThat(configCaptor.firstValue)
|
|
1100
|
+
.hasFieldEqualTo(
|
|
1101
|
+
"additionalConfig",
|
|
1102
|
+
mapOf(
|
|
1103
|
+
DdSdk.DD_VERSION_SUFFIX to versionSuffix,
|
|
1104
|
+
DdSdk.DD_VERSION to mockPackageInfo.versionName + versionSuffix
|
|
1105
|
+
)
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
// endregion
|
|
1110
|
+
|
|
1111
|
+
// region misc
|
|
1112
|
+
|
|
1113
|
+
@Test
|
|
1114
|
+
fun `𝕄 set native user info 𝕎 setUser()`(
|
|
1115
|
+
@MapForgery(
|
|
1116
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1117
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1118
|
+
) extraInfo: Map<String, String>
|
|
1119
|
+
) {
|
|
1120
|
+
// When
|
|
1121
|
+
testedBridgeSdk.setUser(extraInfo.toReadableMap(), mockPromise)
|
|
1122
|
+
|
|
1123
|
+
// Then
|
|
1124
|
+
argumentCaptor<Map<String, Any?>> {
|
|
1125
|
+
verify(mockDatadog)
|
|
1126
|
+
.setUserInfo(
|
|
1127
|
+
isNull(),
|
|
1128
|
+
isNull(),
|
|
1129
|
+
isNull(),
|
|
1130
|
+
capture()
|
|
1131
|
+
)
|
|
1132
|
+
|
|
1133
|
+
assertThat(firstValue)
|
|
1134
|
+
.containsAllEntriesOf(extraInfo)
|
|
1135
|
+
.hasSize(extraInfo.size)
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
@Test
|
|
1140
|
+
fun `𝕄 set native user info 𝕎 setUser() {with id}`(
|
|
1141
|
+
@StringForgery id: String,
|
|
1142
|
+
@MapForgery(
|
|
1143
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1144
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1145
|
+
) extraInfo: Map<String, String>
|
|
1146
|
+
) {
|
|
1147
|
+
// Given
|
|
1148
|
+
val user = extraInfo.toMutableMap().also {
|
|
1149
|
+
it.put("id", id)
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// When
|
|
1153
|
+
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
1154
|
+
|
|
1155
|
+
// Then
|
|
1156
|
+
argumentCaptor<Map<String, Any?>> {
|
|
1157
|
+
verify(mockDatadog)
|
|
1158
|
+
.setUserInfo(
|
|
1159
|
+
eq(id),
|
|
1160
|
+
isNull(),
|
|
1161
|
+
isNull(),
|
|
1162
|
+
capture()
|
|
1163
|
+
)
|
|
1164
|
+
|
|
1165
|
+
assertThat(firstValue)
|
|
1166
|
+
.containsAllEntriesOf(extraInfo)
|
|
1167
|
+
.hasSize(extraInfo.size)
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
@Test
|
|
1172
|
+
fun `𝕄 set native user info 𝕎 setUser() {with name}`(
|
|
1173
|
+
@StringForgery name: String,
|
|
1174
|
+
@MapForgery(
|
|
1175
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1176
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1177
|
+
) extraInfo: Map<String, String>
|
|
1178
|
+
) {
|
|
1179
|
+
// Given
|
|
1180
|
+
val user = extraInfo.toMutableMap().also {
|
|
1181
|
+
it.put("name", name)
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
// When
|
|
1185
|
+
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
1186
|
+
|
|
1187
|
+
// Then
|
|
1188
|
+
argumentCaptor<Map<String, Any?>> {
|
|
1189
|
+
verify(mockDatadog)
|
|
1190
|
+
.setUserInfo(
|
|
1191
|
+
isNull(),
|
|
1192
|
+
eq(name),
|
|
1193
|
+
isNull(),
|
|
1194
|
+
capture()
|
|
1195
|
+
)
|
|
1196
|
+
|
|
1197
|
+
assertThat(firstValue)
|
|
1198
|
+
.containsAllEntriesOf(extraInfo)
|
|
1199
|
+
.hasSize(extraInfo.size)
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
@Test
|
|
1204
|
+
fun `𝕄 set native user info 𝕎 setUser() {with email}`(
|
|
1205
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String,
|
|
1206
|
+
@MapForgery(
|
|
1207
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1208
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1209
|
+
) extraInfo: Map<String, String>
|
|
1210
|
+
) {
|
|
1211
|
+
// Given
|
|
1212
|
+
val user = extraInfo.toMutableMap().also {
|
|
1213
|
+
it.put("email", email)
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// When
|
|
1217
|
+
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
1218
|
+
|
|
1219
|
+
// Then
|
|
1220
|
+
argumentCaptor<Map<String, Any?>> {
|
|
1221
|
+
verify(mockDatadog)
|
|
1222
|
+
.setUserInfo(
|
|
1223
|
+
isNull(),
|
|
1224
|
+
isNull(),
|
|
1225
|
+
eq(email),
|
|
1226
|
+
capture()
|
|
1227
|
+
)
|
|
1228
|
+
|
|
1229
|
+
assertThat(firstValue)
|
|
1230
|
+
.containsAllEntriesOf(extraInfo)
|
|
1231
|
+
.hasSize(extraInfo.size)
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
@Test
|
|
1236
|
+
fun `𝕄 set native user info 𝕎 setUser() {with id, name and email}`(
|
|
1237
|
+
@StringForgery id: String,
|
|
1238
|
+
@StringForgery name: String,
|
|
1239
|
+
@StringForgery(regex = "\\w+@\\w+\\.[a-z]{3}") email: String,
|
|
1240
|
+
@MapForgery(
|
|
1241
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1242
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1243
|
+
) extraInfo: Map<String, String>
|
|
1244
|
+
) {
|
|
1245
|
+
// Given
|
|
1246
|
+
val user = extraInfo.toMutableMap().also {
|
|
1247
|
+
it.put("id", id)
|
|
1248
|
+
it.put("name", name)
|
|
1249
|
+
it.put("email", email)
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// When
|
|
1253
|
+
testedBridgeSdk.setUser(user.toReadableMap(), mockPromise)
|
|
1254
|
+
|
|
1255
|
+
// Then
|
|
1256
|
+
argumentCaptor<Map<String, Any?>> {
|
|
1257
|
+
verify(mockDatadog)
|
|
1258
|
+
.setUserInfo(
|
|
1259
|
+
eq(id),
|
|
1260
|
+
eq(name),
|
|
1261
|
+
eq(email),
|
|
1262
|
+
capture()
|
|
1263
|
+
)
|
|
1264
|
+
|
|
1265
|
+
assertThat(firstValue)
|
|
1266
|
+
.containsAllEntriesOf(extraInfo)
|
|
1267
|
+
.hasSize(extraInfo.size)
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
@Test
|
|
1272
|
+
fun `𝕄 set RUM attributes 𝕎 setAttributes`(
|
|
1273
|
+
@MapForgery(
|
|
1274
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1275
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1276
|
+
) customAttributes: Map<String, String>
|
|
1277
|
+
) {
|
|
1278
|
+
// When
|
|
1279
|
+
testedBridgeSdk.setAttributes(customAttributes.toReadableMap(), mockPromise)
|
|
1280
|
+
|
|
1281
|
+
// Then
|
|
1282
|
+
verify(mockDatadog).addRumGlobalAttributes(customAttributes)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
@Test
|
|
1286
|
+
fun `𝕄 set GlobalState attributes 𝕎 setAttributes`(
|
|
1287
|
+
@MapForgery(
|
|
1288
|
+
key = AdvancedForgery(string = [StringForgery(StringForgeryType.NUMERICAL)]),
|
|
1289
|
+
value = AdvancedForgery(string = [StringForgery(StringForgeryType.ASCII)])
|
|
1290
|
+
) customAttributes: Map<String, String>
|
|
1291
|
+
) {
|
|
1292
|
+
// When
|
|
1293
|
+
testedBridgeSdk.setAttributes(customAttributes.toReadableMap(), mockPromise)
|
|
1294
|
+
|
|
1295
|
+
// Then
|
|
1296
|
+
customAttributes.forEach { (k, v) ->
|
|
1297
|
+
assertThat(GlobalState.globalAttributes).containsEntry(k, v)
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
@Test
|
|
1302
|
+
fun `𝕄 build Granted consent 𝕎 buildTrackingConsent {granted}`(forge: Forge) {
|
|
1303
|
+
|
|
1304
|
+
// When
|
|
1305
|
+
val consent = testedBridgeSdk.buildTrackingConsent(
|
|
1306
|
+
forge.anElementFrom("granted", "GRANTED")
|
|
1307
|
+
)
|
|
1308
|
+
|
|
1309
|
+
// Then
|
|
1310
|
+
assertThat(consent).isEqualTo(TrackingConsent.GRANTED)
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
@Test
|
|
1314
|
+
fun `𝕄 build Pending consent 𝕎 buildTrackingConsent {pending}`(forge: Forge) {
|
|
1315
|
+
|
|
1316
|
+
// When
|
|
1317
|
+
val consent = testedBridgeSdk.buildTrackingConsent(
|
|
1318
|
+
forge.anElementFrom("pending", "PENDING")
|
|
1319
|
+
)
|
|
1320
|
+
|
|
1321
|
+
// Then
|
|
1322
|
+
assertThat(consent).isEqualTo(TrackingConsent.PENDING)
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
@Test
|
|
1326
|
+
fun `𝕄 build Granted consent 𝕎 buildTrackingConsent {not_granted}`(forge: Forge) {
|
|
1327
|
+
|
|
1328
|
+
// When
|
|
1329
|
+
val consent = testedBridgeSdk.buildTrackingConsent(
|
|
1330
|
+
forge.anElementFrom("not_granted", "NOT_GRANTED")
|
|
1331
|
+
)
|
|
1332
|
+
|
|
1333
|
+
// Then
|
|
1334
|
+
assertThat(consent).isEqualTo(TrackingConsent.NOT_GRANTED)
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
@Test
|
|
1338
|
+
fun `𝕄 build default Pending consent 𝕎 buildTrackingConsent {any}`(forge: Forge) {
|
|
1339
|
+
|
|
1340
|
+
// When
|
|
1341
|
+
val consent = testedBridgeSdk.buildTrackingConsent(
|
|
1342
|
+
forge.anElementFrom(null, "some-type")
|
|
1343
|
+
)
|
|
1344
|
+
|
|
1345
|
+
// Then
|
|
1346
|
+
assertThat(consent).isEqualTo(TrackingConsent.PENDING)
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
@Test
|
|
1350
|
+
fun `𝕄 call setTrackingConsent 𝕎 setTrackingConsent ()`(forge: Forge) {
|
|
1351
|
+
|
|
1352
|
+
// Given
|
|
1353
|
+
val consent = forge.anElementFrom("pending", "granted", "not_granted")
|
|
1354
|
+
|
|
1355
|
+
// When
|
|
1356
|
+
testedBridgeSdk.setTrackingConsent(consent, mockPromise)
|
|
1357
|
+
|
|
1358
|
+
// Then
|
|
1359
|
+
verify(mockDatadog).setTrackingConsent(consent.asTrackingConsent())
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
@Test
|
|
1363
|
+
fun `𝕄 not build proxy config 𝕎 no proxy config specified`(
|
|
1364
|
+
@Forgery configuration: DdSdkConfiguration
|
|
1365
|
+
) {
|
|
1366
|
+
|
|
1367
|
+
// Given
|
|
1368
|
+
val config = configuration.copy(additionalConfig = null)
|
|
1369
|
+
|
|
1370
|
+
// When
|
|
1371
|
+
val proxyConfig = testedBridgeSdk.buildProxyConfiguration(config)
|
|
1372
|
+
|
|
1373
|
+
// Then
|
|
1374
|
+
assertThat(proxyConfig).isNull()
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
@Test
|
|
1378
|
+
fun `𝕄 not build proxy config 𝕎 buildProxyConfiguration() { type is missing }`(
|
|
1379
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1380
|
+
forge: Forge
|
|
1381
|
+
) {
|
|
1382
|
+
// Given
|
|
1383
|
+
val additionalConfig = mapOf(
|
|
1384
|
+
DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
|
|
1385
|
+
DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
|
|
1386
|
+
)
|
|
1387
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1388
|
+
|
|
1389
|
+
// When
|
|
1390
|
+
val proxyConfig = testedBridgeSdk.buildProxyConfiguration(config)
|
|
1391
|
+
|
|
1392
|
+
// Then
|
|
1393
|
+
assertThat(proxyConfig).isNull()
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
@Test
|
|
1397
|
+
fun `𝕄 not build proxy config 𝕎 buildProxyConfiguration() { wrong type is used } `(
|
|
1398
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1399
|
+
forge: Forge
|
|
1400
|
+
) {
|
|
1401
|
+
// Given
|
|
1402
|
+
|
|
1403
|
+
val proxyType = forge.anAlphabeticalString()
|
|
1404
|
+
assumeTrue(proxyType.lowercase(Locale.US) !in arrayOf("http", "https", "socks"))
|
|
1405
|
+
|
|
1406
|
+
val additionalConfig = mapOf(
|
|
1407
|
+
DdSdk.DD_PROXY_TYPE to proxyType,
|
|
1408
|
+
DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
|
|
1409
|
+
DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
|
|
1410
|
+
)
|
|
1411
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1412
|
+
|
|
1413
|
+
// When
|
|
1414
|
+
val proxyConfig = testedBridgeSdk.buildProxyConfiguration(config)
|
|
1415
|
+
|
|
1416
|
+
// Then
|
|
1417
|
+
assertThat(proxyConfig).isNull()
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
@Test
|
|
1421
|
+
fun `𝕄 not build proxy config 𝕎 buildProxyConfiguration() { address is missing }`(
|
|
1422
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1423
|
+
forge: Forge
|
|
1424
|
+
) {
|
|
1425
|
+
// Given
|
|
1426
|
+
val additionalConfig = mapOf(
|
|
1427
|
+
DdSdk.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
|
|
1428
|
+
DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
|
|
1429
|
+
)
|
|
1430
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1431
|
+
|
|
1432
|
+
// When
|
|
1433
|
+
val proxyConfig = testedBridgeSdk.buildProxyConfiguration(config)
|
|
1434
|
+
|
|
1435
|
+
// Then
|
|
1436
|
+
assertThat(proxyConfig).isNull()
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
@Test
|
|
1440
|
+
fun `𝕄 not build proxy config 𝕎 buildProxyConfiguration() { port is missing }`(
|
|
1441
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1442
|
+
forge: Forge
|
|
1443
|
+
) {
|
|
1444
|
+
// Given
|
|
1445
|
+
val additionalConfig = mapOf(
|
|
1446
|
+
DdSdk.DD_PROXY_TYPE to forge.anElementFrom("http", "https", "socks"),
|
|
1447
|
+
DdSdk.DD_PROXY_ADDRESS to "1.1.1.1"
|
|
1448
|
+
)
|
|
1449
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1450
|
+
|
|
1451
|
+
// When
|
|
1452
|
+
val proxyConfig = testedBridgeSdk.buildProxyConfiguration(config)
|
|
1453
|
+
|
|
1454
|
+
// Then
|
|
1455
|
+
assertThat(proxyConfig).isNull()
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
@Test
|
|
1459
|
+
fun `𝕄 build proxy configuration 𝕎 buildProxyConfiguration() { no credentials }`(
|
|
1460
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1461
|
+
forge: Forge
|
|
1462
|
+
) {
|
|
1463
|
+
// Given
|
|
1464
|
+
val proxyType = forge.anElementFrom("http", "https", "socks")
|
|
1465
|
+
|
|
1466
|
+
val additionalConfig = mapOf(
|
|
1467
|
+
DdSdk.DD_PROXY_TYPE to proxyType,
|
|
1468
|
+
DdSdk.DD_PROXY_ADDRESS to "1.1.1.1",
|
|
1469
|
+
DdSdk.DD_PROXY_PORT to forge.anInt(min = 0, max = 65536)
|
|
1470
|
+
)
|
|
1471
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1472
|
+
|
|
1473
|
+
// When
|
|
1474
|
+
val (proxy, authenticator) = testedBridgeSdk.buildProxyConfiguration(config)!!
|
|
1475
|
+
|
|
1476
|
+
// Then
|
|
1477
|
+
assertThat(proxy.type()).matches {
|
|
1478
|
+
when (proxyType) {
|
|
1479
|
+
"http", "https" -> it == Proxy.Type.HTTP
|
|
1480
|
+
else -> it == Proxy.Type.SOCKS
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
assertThat(proxy.address()).isNotNull
|
|
1485
|
+
|
|
1486
|
+
assertThat(authenticator).isNull()
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
@Test
|
|
1490
|
+
fun `𝕄 build proxy configuration+authenticator 𝕎 buildProxyConfiguration() { +credentials }`(
|
|
1491
|
+
@Forgery configuration: DdSdkConfiguration,
|
|
1492
|
+
forge: Forge
|
|
1493
|
+
) {
|
|
1494
|
+
// Given
|
|
1495
|
+
val proxyType = forge.anElementFrom("http", "https", "socks")
|
|
1496
|
+
val proxyUsername = forge.anAlphabeticalString()
|
|
1497
|
+
val proxyPassword = forge.anAlphabeticalString()
|
|
1498
|
+
val proxyPort = forge.anInt(min = 0, max = 65536)
|
|
1499
|
+
val proxyAddress = "1.1.1.1"
|
|
1500
|
+
|
|
1501
|
+
val additionalConfig = mapOf(
|
|
1502
|
+
DdSdk.DD_PROXY_TYPE to proxyType,
|
|
1503
|
+
DdSdk.DD_PROXY_ADDRESS to proxyAddress,
|
|
1504
|
+
DdSdk.DD_PROXY_PORT to proxyPort,
|
|
1505
|
+
DdSdk.DD_PROXY_USERNAME to proxyUsername,
|
|
1506
|
+
DdSdk.DD_PROXY_PASSWORD to proxyPassword
|
|
1507
|
+
)
|
|
1508
|
+
val config = configuration.copy(additionalConfig = additionalConfig)
|
|
1509
|
+
|
|
1510
|
+
// When
|
|
1511
|
+
val (proxy, authenticator) = testedBridgeSdk.buildProxyConfiguration(config)!!
|
|
1512
|
+
|
|
1513
|
+
// Then
|
|
1514
|
+
assertThat(proxy.type()).matches {
|
|
1515
|
+
when (proxyType) {
|
|
1516
|
+
"http", "https" -> it == Proxy.Type.HTTP
|
|
1517
|
+
else -> it == Proxy.Type.SOCKS
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
assertThat(proxy.address()).isNotNull
|
|
1522
|
+
assertThat(proxy.address()).isInstanceOf(InetSocketAddress::class.java)
|
|
1523
|
+
(proxy.address() as InetSocketAddress).let {
|
|
1524
|
+
assertThat(it.port).isEqualTo(proxyPort)
|
|
1525
|
+
assertThat(it.address.hostAddress).isEqualTo(proxyAddress)
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
assertThat(authenticator).isNotNull
|
|
1529
|
+
assertThat(authenticator?.username).isEqualTo(proxyUsername)
|
|
1530
|
+
assertThat(authenticator?.password).isEqualTo(proxyPassword)
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
// endregion
|
|
1534
|
+
|
|
1535
|
+
// region Internal
|
|
1536
|
+
|
|
1537
|
+
private fun String?.asTrackingConsent(): TrackingConsent {
|
|
1538
|
+
return when (this?.lowercase(Locale.US)) {
|
|
1539
|
+
"pending" -> TrackingConsent.PENDING
|
|
1540
|
+
"granted" -> TrackingConsent.GRANTED
|
|
1541
|
+
"not_granted" -> TrackingConsent.NOT_GRANTED
|
|
1542
|
+
else -> TrackingConsent.PENDING
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
// endregion
|
|
1547
|
+
}
|