Skip to content

Commit

Permalink
Merge pull request #70 from velocitycareerlabs/VL-6359-dev-to-rc
Browse files Browse the repository at this point in the history
Vl 6359 dev to rc
  • Loading branch information
michaelavoyan authored Dec 25, 2023
2 parents 6efa94c + 77c5895 commit 3e4ff67
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
4 changes: 2 additions & 2 deletions VCL/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
defaultConfig {
minSdk 24
targetSdk 33
versionName "1.21.5"
versionCode 117
versionName "1.22.0"
versionCode 118
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
Expand Down
25 changes: 23 additions & 2 deletions VCL/src/main/java/io/velocitycareerlabs/api/entities/VCLToken.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/

package io.velocitycareerlabs.api.entities

data class VCLToken(val value: String)
data class VCLToken(
/**
* token value represented as jwt string
*/
val value: String
) {
/**
* token value represented as VCLJwt object
*/
val jwtValue = VCLJwt(value)

constructor(jwtValue: VCLJwt) : this(jwtValue.encodedJwt ?: "")

/**
* token expiration period in milliseconds
*/
val expiresIn: Long?
get() = jwtValue.signedJwt?.payload?.toJSONObject()?.get(CodingKeys.KeyExp) as? Long

companion object CodingKeys {
const val KeyExp = "exp"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/**
* Created by Michael Avoyan on 11/12/2022.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/

package io.velocitycareerlabs.entities
Expand Down
33 changes: 33 additions & 0 deletions VCL/src/test/java/io/velocitycareerlabs/entities/VCLTokenTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Created by Michael Avoyan on 24/12/2023.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
package io.velocitycareerlabs.entities

import io.velocitycareerlabs.api.entities.VCLToken
import io.velocitycareerlabs.infrastructure.resources.valid.TokenMocks
import org.junit.Test

class VCLTokenTest {
lateinit var subject: VCLToken

@Test
fun testToken1() {
subject = VCLToken(value = TokenMocks.TokenStr)

assert(subject.value == TokenMocks.TokenStr)
assert(subject.jwtValue.encodedJwt == TokenMocks.TokenStr)
assert(subject.expiresIn == 1704020514L)
}

@Test
fun testToken2() {
subject = VCLToken(jwtValue = TokenMocks.TokenJwt)

assert(subject.value == TokenMocks.TokenJwt.encodedJwt)
assert(subject.jwtValue.encodedJwt == TokenMocks.TokenJwt.encodedJwt)
assert(subject.expiresIn == 1704020514L)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Created by Michael Avoyan on 24/12/2023.
*
* Copyright 2022 Velocity Career Labs inc.
* SPDX-License-Identifier: Apache-2.0
*/
package io.velocitycareerlabs.infrastructure.resources.valid

import io.velocitycareerlabs.api.entities.VCLJwt

class TokenMocks {
companion object {
const val TokenStr =
"eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiI2NTg4MGY5ZThkMjY3NWE0NTBhZDVhYjgiLCJpc3MiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJhdWQiOiJkaWQ6aW9uOkVpQXBNTGRNYjROUGI4c2FlOS1oWEdIUDc5VzFnaXNBcFZTRTgwVVNQRWJ0SkEiLCJleHAiOjE3MDQwMjA1MTQsInN1YiI6IjYzODZmODI0ZTc3NDc4OWM0MDNjOTZhMCIsImlhdCI6MTcwMzQxNTcxNH0.AJwKvQ_YNviFTjcuoJUR7ZHFEIbKY9zLCJv4DfC_PPk3Q-15rwKucYy8GdlfKnHLioBA5X37lpG-js8EztEKDg"
val TokenJwt = VCLJwt(encodedJwt = TokenMocks.TokenStr)
}
}

0 comments on commit 3e4ff67

Please sign in to comment.