Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2ei): set claims in OAuth flow #2623

Merged
merged 5 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
}, {
if (it is E2EIEnrollmentResult.Initialized) {
initialEnrollmentResult = it
OAuthUseCase(context, it.target, it.oAuthState).launch(
OAuthUseCase(context, it.target, it.oAuthClaims, it.oAuthState).launch(

Check warning on line 51 in app/src/main/kotlin/com/wire/android/feature/e2ei/GetE2EICertificateUseCase.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/feature/e2ei/GetE2EICertificateUseCase.kt#L51

Added line #L51 was not covered by tests
context.getActivity()!!.activityResultRegistry,
::oAuthResultHandler
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.activity.result.contract.ActivityResultContracts
import com.wire.android.appLogger
import com.wire.android.util.deeplink.DeepLinkProcessor
import kotlinx.serialization.json.JsonObject
import net.openid.appauth.AppAuthConfiguration
import net.openid.appauth.AuthState
import net.openid.appauth.AuthorizationException
Expand All @@ -41,6 +42,7 @@
import net.openid.appauth.browser.BrowserAllowList
import net.openid.appauth.browser.VersionedBrowserMatcher
import net.openid.appauth.connectivity.ConnectionBuilder
import org.json.JSONObject
import java.net.HttpURLConnection
import java.net.URL
import java.security.MessageDigest
Expand All @@ -52,7 +54,7 @@
import javax.net.ssl.TrustManager
import javax.net.ssl.X509TrustManager

class OAuthUseCase(context: Context, private val authUrl: String, oAuthState: String?) {
class OAuthUseCase(context: Context, private val authUrl: String, private val claims: JsonObject, oAuthState: String?) {

Check warning on line 57 in app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt#L57

Added line #L57 was not covered by tests
private var authState: AuthState = oAuthState?.let {
AuthState.jsonDeserialize(it)
} ?: AuthState()
Expand Down Expand Up @@ -177,7 +179,8 @@
AuthorizationRequest.Scope.EMAIL,
AuthorizationRequest.Scope.PROFILE,
AuthorizationRequest.Scope.OFFLINE_ACCESS
).build()
).setClaims(JSONObject(claims.toString()))
.build()

Check warning on line 183 in app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/feature/e2ei/OAuthUseCase.kt#L182-L183

Added lines #L182 - L183 were not covered by tests

private fun AuthorizationRequest.Builder.setCodeVerifier(): AuthorizationRequest.Builder {
val codeVerifier = getCodeVerifier()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.verify
import kotlinx.coroutines.test.runTest
import org.amshove.kluent.internal.assertEquals
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -77,7 +76,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}
}
Expand Down Expand Up @@ -114,7 +113,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}
}
Expand Down Expand Up @@ -170,7 +169,7 @@ class SearchUserViewModelTest {
)
}

verify(exactly = 1) {
coVerify(exactly = 1) {
arrangement.federatedSearchParser(any())
}

Expand Down
2 changes: 1 addition & 1 deletion kalium
Submodule kalium updated 86 files
+13 −2 .github/workflows/cherry-pick-rc-to-develop.yml
+3 −2 cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/E2EIClientImpl.kt
+3 −2 cryptography/src/commonMain/kotlin/com/wire/kalium/cryptography/E2EIClient.kt
+1 −1 gradle/libs.versions.toml
+21 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/configuration/UserConfigRepository.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/conversation/MLSConversationRepository.kt
+12 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/e2ei/E2EIRepository.kt
+1 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperImpl.kt
+26 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/MessageRepository.kt
+12 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/message/ProtoContentMapper.kt
+2 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/data/session/SessionRepository.kt
+25 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
+3 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/ConversationScope.kt
+5 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/conversation/NotifyConversationIsOpenUseCase.kt
+56 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/CheckRevocationListUseCase.kt
+24 −1 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/EnrollE2EIUseCase.kt
+47 −0 ...nMain/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/ObserveCertificateRevocationForSelfClientUseCase.kt
+1 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MLSMessageCreator.kt
+15 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/MessageScope.kt
+79 −0 ...onMain/kotlin/com/wire/kalium/logic/feature/message/composite/SendButtonActionConfirmationMessageUseCase.kt
+34 −0 ...c/commonMain/kotlin/com/wire/kalium/logic/feature/message/ephemeral/DeleteEphemeralMessageEndDateUseCase.kt
+24 −0 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/message/ephemeral/EphemeralMessageDeletionHandler.kt
+23 −9 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/search/FederatedSearchParser.kt
+13 −2 logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/user/UserScope.kt
+35 −0 ...mmonMain/kotlin/com/wire/kalium/logic/feature/user/e2ei/MarkNotifyForRevokedCertificateAsNotifiedUseCase.kt
+47 −0 ...ommonMain/kotlin/com/wire/kalium/logic/feature/user/e2ei/ObserveShouldNotifyForRevokedCertificateUseCase.kt
+3 −2 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/asset/AssetRepositoryTest.kt
+2 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/e2ei/E2EIRepositoryTest.kt
+4 −4 logic/src/commonTest/kotlin/com/wire/kalium/logic/data/id/FederatedIdMapperTest.kt
+24 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/conversation/NotifyConversationIsOpenUseCaseTest.kt
+25 −2 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/EnrollE2EICertificateUseCaseTest.kt
+266 −0 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/e2ei/usecase/CheckRevocationListUseCaseTest.kt
+100 −0 ...ommonTest/kotlin/com/wire/kalium/logic/feature/message/composite/SendButtonActionConfirmationMessageTest.kt
+61 −0 ...st/kotlin/com/wire/kalium/logic/feature/message/ephemeral/DeleteEphemeralMessagesAfterEndDateUseCaseTest.kt
+34 −0 ...rc/commonTest/kotlin/com/wire/kalium/logic/feature/message/ephemeral/EphemeralMessageDeletionHandlerTest.kt
+5 −4 logic/src/commonTest/kotlin/com/wire/kalium/logic/feature/search/FederatedSearchParserTest.kt
+63 −0 ...Test/kotlin/com/wire/kalium/logic/feature/user/e2ei/MarkNotifyForRevokedCertificateAsNotifiedUseCaseTest.kt
+81 −0 ...nTest/kotlin/com/wire/kalium/logic/feature/user/e2ei/ObserveShouldNotifyForRevokedCertificateUseCaseTest.kt
+1 −1 logic/src/commonTest/kotlin/com/wire/kalium/logic/util/arrangement/repository/SessionRepositoryArrangement.kt
+2 −2 network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt
+6 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/base/unbound/acme/ACMEApi.kt
+1 −1 network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt
+28 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AssetApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/CallApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ClientApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ConnectionApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/ConversationApiV6.kt
+25 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/FeatureConfigApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt
+28 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/LogoutApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt
+28 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MessageApiV6.kt
+30 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/PreKeyApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/PropertiesApiV6.kt
+28 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/SelfApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/TeamsApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/UserDetailsApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/UserSearchApiV6.kt
+134 −0 ...ain/kotlin/com/wire/kalium/network/api/v6/authenticated/networkContainer/AuthenticatedNetworkContainerV6.kt
+25 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/DomainLookupApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/LoginApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/RegisterApiV6.kt
+26 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/SSOLoginApiV6.kt
+25 −0 network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/unauthenticated/VerificationCodeApiV6.kt
+66 −0 ...kotlin/com/wire/kalium/network/api/v6/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV6.kt
+11 −1 network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt
+9 −0 network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt
+1 −0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/MessageDetailsView.sq
+14 −0 persistence/src/commonMain/db_user/com/wire/kalium/persistence/Messages.sq
+167 −0 persistence/src/commonMain/db_user/migrations/73.sqm
+4 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAO.kt
+16 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOImpl.kt
+1 −0 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/message/MessageMapper.kt
+47 −5 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/dao/unread/UserConfigDAO.kt
+5 −3 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/daokaliumdb/AccountsDAO.kt
+2 −1 persistence/src/commonMain/kotlin/com/wire/kalium/persistence/db/TableMapper.kt
+47 −0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageDAOTest.kt
+2 −0 persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/message/MessageMapperTest.kt
+37 −2 testservice/src/main/kotlin/com/wire/kalium/testservice/api/v1/ConversationResources.kt
+65 −0 testservice/src/main/kotlin/com/wire/kalium/testservice/managed/ConversationRepository.kt
+26 −0 testservice/src/main/kotlin/com/wire/kalium/testservice/models/SendButtonActionConfirmationRequest.kt
+25 −0 testservice/src/main/kotlin/com/wire/kalium/testservice/models/SendButtonActionRequest.kt
Loading