mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 03:08:50 +03:00
PM-11236: Add build type and flavor to the user agent (#3797)
This commit is contained in:
parent
86dabea39f
commit
43a6495b98
2 changed files with 5 additions and 2 deletions
|
@ -23,7 +23,7 @@ const val HEADER_KEY_USER_AGENT: String = "User-Agent"
|
|||
*/
|
||||
@Suppress("MaxLineLength")
|
||||
val HEADER_VALUE_USER_AGENT: String =
|
||||
"Bitwarden_Mobile/${BuildConfig.VERSION_NAME} (Android ${Build.VERSION.RELEASE}; SDK ${Build.VERSION.SDK_INT}; Model ${Build.MODEL})"
|
||||
"Bitwarden_Mobile/${BuildConfig.VERSION_NAME} (${BuildConfig.BUILD_TYPE}/${BuildConfig.FLAVOR}) (Android ${Build.VERSION.RELEASE}; SDK ${Build.VERSION.SDK_INT}; Model ${Build.MODEL})"
|
||||
|
||||
/**
|
||||
* The key used for the 'bitwarden-client-name' headers.
|
||||
|
|
|
@ -16,6 +16,8 @@ class HeadersInterceptorTest : BaseRobolectricTest() {
|
|||
// We reference the real BuildConfig here, since we don't want the test to break on every
|
||||
// version bump. We are also doing the same thing for Build when the SDK gets incremented.
|
||||
val versionName = BuildConfig.VERSION_NAME
|
||||
val buildType = BuildConfig.BUILD_TYPE
|
||||
val flavor = BuildConfig.FLAVOR
|
||||
val release = Build.VERSION.RELEASE
|
||||
val sdk = Build.VERSION.SDK_INT
|
||||
val originalRequest = Request.Builder().url("http://www.fake.com/").build()
|
||||
|
@ -24,8 +26,9 @@ class HeadersInterceptorTest : BaseRobolectricTest() {
|
|||
val response = headersInterceptors.intercept(chain)
|
||||
|
||||
val request = response.request
|
||||
@Suppress("MaxLineLength")
|
||||
assertEquals(
|
||||
"Bitwarden_Mobile/$versionName (Android $release; SDK $sdk; Model robolectric)",
|
||||
"Bitwarden_Mobile/$versionName ($buildType/$flavor) (Android $release; SDK $sdk; Model robolectric)",
|
||||
request.header("User-Agent"),
|
||||
)
|
||||
assertEquals("mobile", request.header("Bitwarden-Client-Name"))
|
||||
|
|
Loading…
Add table
Reference in a new issue