Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
megamegax committed Nov 23, 2023
2 parents af0b769 + 833f7c9 commit 5505560
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_tag_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
run: echo $ANDROID_HOME > local.properties

- name: Release with Gradle
run: ./gradlew clean assembleRelease publishToSonatype
run: ./gradlew clean assembleRelease && ./gradlew publishToSonatype

- name: Create file 'FAILURE.TXT' and write 'true' into it
if: ${{ failure() }}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$Versions.kotlin_version"
classpath "com.github.ben-manes:gradle-versions-plugin:0.47.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.7.2"
classpath "io.github.gradle-nexus:publish-plugin:1.3.0"
}
}
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Config {
const val minApiLevel = 24
const val targetApiLevel = 33
const val targetApiLevel = 34
const val buildToolsVersion = Versions.buildToolsVersion
}
10 changes: 2 additions & 8 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# What's changed
# What's fixed

### [Emarsys SDK](https://github.com/emartech/android-emarsys-sdk)

* Proguard rule added for Emarsys SDK to prevent issues when host application uses R8# What's
changed

### [Emarsys SDK](https://github.com/emartech/android-emarsys-sdk)

* Prevent requests without an application code from being sent and return an
InvalidArgumentException instead through the CompletionListener
* Fixed a possible security vulnerability around push messages
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import com.emarsys.testUtil.InstrumentationRegistry.Companion.getTargetContext
import com.emarsys.testUtil.TestUrls.DENNA_ECHO
import com.emarsys.testUtil.TimeoutUtils.timeoutRule
import org.json.JSONObject
import org.junit.*
import org.junit.After
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule
import org.mockito.kotlin.any
import org.mockito.kotlin.doAnswer
Expand Down Expand Up @@ -132,10 +136,10 @@ class RequestManagerDennaTest {
Assert.assertEquals(200, fakeCompletionHandler.successResponseModel.statusCode.toLong())
val responseJson = JSONObject(fakeCompletionHandler.successResponseModel.body!!)
val headers = responseJson["headers"] as JSONObject
Assert.assertEquals("value1", headers["Header1"])
Assert.assertEquals("value2", headers["Header2"])
Assert.assertEquals("application/json", headers["Accept"])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content"])
Assert.assertEquals("value1", headers["Header1".lowercase()])
Assert.assertEquals("value2", headers["Header2".lowercase()])
Assert.assertEquals("application/json", headers["Accept".lowercase()])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content".lowercase()])
Assert.assertEquals("GET", responseJson["method"])
Assert.assertFalse(responseJson.has("body"))
}
Expand Down Expand Up @@ -166,10 +170,10 @@ class RequestManagerDennaTest {
val responseJson = JSONObject(fakeCompletionHandler.successResponseModel.body!!)
val headers = responseJson.getJSONObject("headers")
val body = responseJson.getJSONObject("body")
Assert.assertEquals("value1", headers["Header1"])
Assert.assertEquals("value2", headers["Header2"])
Assert.assertEquals("application/json", headers["Accept"])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content"])
Assert.assertEquals("value1", headers["Header1".lowercase()])
Assert.assertEquals("value2", headers["Header2".lowercase()])
Assert.assertEquals("application/json", headers["Accept".lowercase()])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content".lowercase()])
Assert.assertEquals("POST", responseJson["method"])
Assert.assertEquals("val1", body["key1"])
Assert.assertEquals("val2", body["key2"])
Expand All @@ -194,10 +198,10 @@ class RequestManagerDennaTest {
Assert.assertEquals(200, fakeCompletionHandler.successResponseModel.statusCode.toLong())
val responseJson = JSONObject(fakeCompletionHandler.successResponseModel!!.body!!)
val headers = responseJson.getJSONObject("headers")
Assert.assertEquals("value1", headers["Header1"])
Assert.assertEquals("value2", headers["Header2"])
Assert.assertEquals("application/json", headers["Accept"])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content"])
Assert.assertEquals("value1", headers["Header1".lowercase()])
Assert.assertEquals("value2", headers["Header2".lowercase()])
Assert.assertEquals("application/json", headers["Accept".lowercase()])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content".lowercase()])
Assert.assertEquals("PUT", responseJson["method"])
Assert.assertFalse(responseJson.has("body"))
}
Expand All @@ -216,10 +220,10 @@ class RequestManagerDennaTest {
Assert.assertEquals(200, fakeCompletionHandler.successResponseModel.statusCode.toLong())
val responseJson = JSONObject(fakeCompletionHandler.successResponseModel!!.body!!)
val headers = responseJson.getJSONObject("headers")
Assert.assertEquals("value1", headers["Header1"])
Assert.assertEquals("value2", headers["Header2"])
Assert.assertEquals("application/json", headers["Accept"])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content"])
Assert.assertEquals("value1", headers["Header1".lowercase()])
Assert.assertEquals("value2", headers["Header2".lowercase()])
Assert.assertEquals("application/json", headers["Accept".lowercase()])
Assert.assertEquals("application/x-www-form-urlencoded", headers["Content".lowercase()])
Assert.assertEquals("DELETE", responseJson["method"])
Assert.assertFalse(responseJson.has("body"))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.emarsys


import android.app.Application
import android.content.Context
import com.emarsys.config.EmarsysConfig
import com.emarsys.core.DefaultCoreCompletionHandler
import com.emarsys.core.api.result.Try
import com.emarsys.core.device.DeviceInfo
import com.emarsys.core.device.LanguageProvider



import com.emarsys.core.notification.NotificationManagerHelper
import com.emarsys.core.provider.hardwareid.HardwareIdProvider
import com.emarsys.core.provider.version.VersionProvider
Expand All @@ -18,20 +16,28 @@ import com.emarsys.core.storage.Storage
import com.emarsys.di.DefaultEmarsysComponent
import com.emarsys.di.DefaultEmarsysDependencies
import com.emarsys.di.emarsys

import com.emarsys.predict.api.model.PredictCartItem
import com.emarsys.predict.api.model.Product
import com.emarsys.predict.api.model.RecommendationFilter
import com.emarsys.predict.api.model.RecommendationLogic
import com.emarsys.predict.util.CartItemUtils
import com.emarsys.testUtil.*
import com.emarsys.testUtil.ConnectionTestUtils
import com.emarsys.testUtil.DatabaseTestUtils
import com.emarsys.testUtil.FeatureTestUtils
import com.emarsys.testUtil.InstrumentationRegistry
import com.emarsys.testUtil.IntegrationTestUtils
import com.emarsys.testUtil.RetryUtils
import com.emarsys.testUtil.TimeoutUtils
import com.emarsys.testUtil.mockito.whenever
import com.emarsys.testUtil.rules.DuplicatedThreadRule
import com.emarsys.testUtil.rules.RetryRule
import io.kotlintest.matchers.numerics.shouldBeGreaterThan
import io.kotlintest.shouldBe
import io.kotlintest.shouldNotBe
import org.junit.*
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestRule
import org.mockito.ArgumentMatchers
import org.mockito.Mockito.mock
Expand All @@ -45,6 +51,11 @@ class PredictIntegrationTest {
private const val CONTACT_FIELD_ID = 3
private const val MERCHANT_ID = "1428C8EE286EC34B"
private const val OTHER_MERCHANT_ID = "test_1428C8EE286EC34B"
const val ITEM1 = "12800"
const val ITEM2 = "13433"
const val ITEM3 = "9129-P"
const val SEARCH_TERM = "Ropa"
const val CATEGORY_PATH = "Ropa bebe nina>Ropa Interior"
}

private lateinit var latch: CountDownLatch
Expand Down Expand Up @@ -165,9 +176,9 @@ class PredictIntegrationTest {
@Test
fun testTrackCart() {
val cartItems = listOf(
PredictCartItem("2168", 1.1, 10.0),
PredictCartItem("2200", 2.2, 20.0),
PredictCartItem("2509", 3.3, 30.0)
PredictCartItem(ITEM1, 1.1, 10.0),
PredictCartItem(ITEM2, 2.2, 20.0),
PredictCartItem(ITEM3, 3.3, 30.0)
)

responseModelMatches = {
Expand All @@ -182,9 +193,9 @@ class PredictIntegrationTest {
@Test
fun testTrackPurchase() {
val cartItems = listOf(
PredictCartItem("2168", 1.1, 10.0),
PredictCartItem("2200", 2.2, 20.0),
PredictCartItem("2509", 3.3, 30.0)
PredictCartItem(ITEM1, 1.1, 10.0),
PredictCartItem(ITEM2, 2.2, 20.0),
PredictCartItem(ITEM3, 3.3, 30.0)
)

val orderId = "orderId_1234567892345678"
Expand All @@ -201,7 +212,7 @@ class PredictIntegrationTest {

@Test
fun testTrackItemView() {
val itemId = "2168"
val itemId = ITEM3
responseModelMatches = {
it.baseUrl.contains(itemId)
}
Expand All @@ -213,7 +224,7 @@ class PredictIntegrationTest {

@Test
fun testTrackItemView_withProduct() {
val product = Product("2168", "TestTitle", "https://emarsys.com", "RELATED", "AAAA")
val product = Product(ITEM3, "TestTitle", "https://emarsys.com", "RELATED", "AAAA")
responseModelMatches = {
it.baseUrl.contains(product.productId)
}
Expand All @@ -225,24 +236,22 @@ class PredictIntegrationTest {

@Test
fun testTrackCategoryView() {
val categoryId = "MEN>Shirts"
responseModelMatches = {
it.baseUrl.contains(categoryId)
it.baseUrl.contains(CATEGORY_PATH)
}

Emarsys.predict.trackCategoryView(categoryId)
Emarsys.predict.trackCategoryView(CATEGORY_PATH)

eventuallyAssertSuccess()
}

@Test
fun testTrackSearchTerm() {
val searchTerm = "polo shirt"
responseModelMatches = {
it.baseUrl.contains(searchTerm)
it.baseUrl.contains(SEARCH_TERM)
}

Emarsys.predict.trackSearchTerm(searchTerm)
Emarsys.predict.trackSearchTerm(SEARCH_TERM)

eventuallyAssertSuccess()
}
Expand All @@ -261,10 +270,12 @@ class PredictIntegrationTest {

@Test
fun testRecommendProducts() {
Emarsys.predict.recommendProducts(RecommendationLogic.search("polo shirt"),
listOf(RecommendationFilter.exclude("price").isValue("")),
3,
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)).eventuallyAssert {
Emarsys.predict.recommendProducts(
RecommendationLogic.search(SEARCH_TERM),
listOf(RecommendationFilter.exclude("price").isValue("")),
3,
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)
).eventuallyAssert {
latch.await()

triedRecommendedProducts.errorCause shouldBe null
Expand All @@ -274,8 +285,10 @@ class PredictIntegrationTest {

@Test
fun testRecommendProducts_withSearch() {
Emarsys.predict.recommendProducts(RecommendationLogic.search("polo shirt"),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter))
Emarsys.predict.recommendProducts(
RecommendationLogic.search(SEARCH_TERM),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)
)

eventuallyAssertForTriedRecommendedProducts()
}
Expand All @@ -294,9 +307,9 @@ class PredictIntegrationTest {
@Test
fun testRecommendProducts_withCart() {
val cartItems = listOf(
PredictCartItem("2168", 1.1, 10.0),
PredictCartItem("2200", 2.2, 20.0),
PredictCartItem("2509", 3.3, 30.0)
PredictCartItem(ITEM1, 1.1, 10.0),
PredictCartItem(ITEM2, 2.2, 20.0),
PredictCartItem(ITEM3, 3.3, 30.0)
)
Emarsys.predict.recommendProducts(RecommendationLogic.cart(cartItems),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter))
Expand All @@ -317,8 +330,10 @@ class PredictIntegrationTest {

@Test
fun testRecommendProducts_withRelated() {
Emarsys.predict.recommendProducts(RecommendationLogic.related("2200"),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter))
Emarsys.predict.recommendProducts(
RecommendationLogic.related(ITEM3),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)
)

eventuallyAssertForTriedRecommendedProducts()
}
Expand Down Expand Up @@ -346,8 +361,10 @@ class PredictIntegrationTest {

@Test
fun testRecommendProducts_withCategory() {
Emarsys.predict.recommendProducts(RecommendationLogic.category("MEN>Shirts"),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter))
Emarsys.predict.recommendProducts(
RecommendationLogic.category(CATEGORY_PATH),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)
)

eventuallyAssertForTriedRecommendedProducts()
}
Expand All @@ -365,8 +382,10 @@ class PredictIntegrationTest {

@Test
fun testRecommendProducts_withAlsoBought() {
Emarsys.predict.recommendProducts(RecommendationLogic.alsoBought("2200"),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter))
Emarsys.predict.recommendProducts(
RecommendationLogic.alsoBought(ITEM1),
eventuallyStoreResultInProperty(this::triedRecommendedProducts.setter)
)

eventuallyAssertForTriedRecommendedProducts()
}
Expand Down
4 changes: 2 additions & 2 deletions emarsys-sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</receiver>
<activity
android:name="com.emarsys.NotificationOpenedActivity"
android:exported="true"
android:theme="@style/Theme.AppCompat.Translucent"></activity>
android:exported="false"
android:theme="@style/Theme.AppCompat.Translucent" />
</application>
</manifest>
Loading

0 comments on commit 5505560

Please sign in to comment.