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: create use case for getting e2ei certificate (WPB-3214) #2129

Merged
merged 16 commits into from
Oct 25, 2023

Conversation

ohassine
Copy link
Member

@ohassine ohassine commented Oct 11, 2023


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Description

In this PR I created

  • a use case to get e2ei certificate that will have 4 different statues
  • a certificate decoder to be use in the above use case, I added bouncy-castle dependency for JVM

Dependencies (Optional)

If there are some other pull requests related to this one (e.g. new releases of frameworks), specify them here.

Needs releases with:

  • GitHub link to other pull request

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Briefly describe how this change was tested and if applicable the exact steps taken to verify that it works as expected.

Notes (Optional)

Specify here any other facts that you think are important for this issue.

Attachments (Optional)

Attachments like images, videos, etc. (drag and drop in the text box)


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

…te_usecase

# Conflicts:
#	logic/src/commonMain/kotlin/com/wire/kalium/logic/feature/UserSessionScope.kt
@github-actions
Copy link
Contributor

github-actions bot commented Oct 11, 2023

Unit Test Results

   463 files     463 suites   3m 4s ⏱️
2 568 tests 2 464 ✔️ 104 💤 0

Results for commit 41927d7.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2023

Codecov Report

Merging #2129 (bbd0f2f) into develop (872981a) will increase coverage by 0.01%.
Report is 3 commits behind head on develop.
The diff coverage is 70.93%.

@@              Coverage Diff              @@
##             develop    #2129      +/-   ##
=============================================
+ Coverage      57.88%   57.90%   +0.01%     
  Complexity        21       21              
=============================================
  Files           1059     1064       +5     
  Lines          40190    40258      +68     
  Branches        3722     3729       +7     
=============================================
+ Hits           23265    23311      +46     
- Misses         15314    15336      +22     
  Partials        1611     1611              
Files Coverage Δ
...c/data/conversation/ConversationGroupRepository.kt 97.65% <100.00%> (+0.04%) ⬆️
...ation/NewGroupConversationSystemMessagesCreator.kt 91.81% <100.00%> (+0.90%) ⬆️
...ature/connection/AcceptConnectionRequestUseCase.kt 100.00% <100.00%> (ø)
...ire/kalium/logic/feature/e2ei/CertificateStatus.kt 100.00% <100.00%> (ø)
.../wire/kalium/logic/feature/e2ei/E2eiCertificate.kt 100.00% <100.00%> (ø)
...um/logic/feature/e2ei/usecase/EnrollE2EIUseCase.kt 100.00% <ø> (ø)
.../feature/e2ei/usecase/GetE2EICertificateUseCase.kt 100.00% <100.00%> (ø)
...re/kalium/logic/sync/receiver/UserEventReceiver.kt 82.25% <100.00%> (+0.59%) ⬆️
...ceiver/conversation/NewConversationEventHandler.kt 89.65% <100.00%> (+0.36%) ⬆️
...otlin/com/wire/kalium/logic/util/E2eiExtensions.kt 100.00% <100.00%> (ø)
... and 12 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50fa995...bbd0f2f. Read the comment docs.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Oct 11, 2023

Datadog Report

All test runs 2115ed9 🔗

2 Total Test Services: 1 Failed, 0 with New Flaky, 1 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Wall Time Branch View
kalium-jvm 1 0 0 582 39 8m 41.66s Link
kalium-ios 0 0 0 2175 121 12m 45.1s Link

❌ Failed Tests (1)

  • givenEmailAndPasswordWhenLoggingInThenRegisterClientAndLogout - PocIntegrationTest - Details

    Expand for error
     java.lang.AssertionError: no expected response was found for POST:https://test.api.com/v1/access/logout
     
     java.lang.AssertionError: no expected response was found for POST:https://test.api.com/v1/access/logout
     	at org.junit.Assert.fail(Assert.java:89)
     	at kotlin.test.junit.JUnitAsserter.fail(JUnitSupport.kt:56)
     	at kotlin.test.AssertionsKt__AssertionsKt.fail(Assertions.kt:520)
     	at kotlin.test.AssertionsKt.fail(Unknown Source)
     	at util.MockUnboundNetworkClient$createMockEngine$1.invokeSuspend(MockUnboundNetworkClient.kt:88)
     	at util.MockUnboundNetworkClient$createMockEngine$1.invoke(MockUnboundNetworkClient.kt)
     	at util.MockUnboundNetworkClient$createMockEngine$1.invoke(MockUnboundNetworkClient.kt)
     ...
    

@ohassine ohassine added the WIP work in progress label Oct 12, 2023
@ohassine ohassine removed the WIP work in progress label Oct 16, 2023
@ohassine ohassine requested review from mchenani, a team, gongracr, borichellow, vitorhugods and Garzas and removed request for a team October 20, 2023 08:17
enum class CertificateStatus {
REVOKED,
EXPIRED,
VALID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: either here as 'Valid(until: Date)' or in the certificate details the expiresAt... to the properties. we need it atleast for the current client's renewal button.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's add it when we need it

Copy link
Contributor

@mchenani mchenani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please add tests for the decoder and the usecase.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Oct 23, 2023

Datadog Report

All test runs 552698e 🔗

2 Total Test Services: 0 Failed, 0 with New Flaky, 2 Passed

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Wall Time Branch View
kalium-ios 0 0 0 2341 119 13m 7.12s Link
kalium-jvm 0 0 0 2464 104 14m 40.01s Link

@ohassine ohassine requested a review from mchenani October 25, 2023 07:53
fun getE2eiCertificate(clientId: ClientId): Either<E2EIFailure, String>
}

class E2eiCertificateRepositoryImpl : E2eiCertificateRepository {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: instead of having a new repository, you an move this function to the E2EIRepository we have at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually E2EIRepository is already doing too much, I think it's better to have a newer one than having a God class.

package com.wire.kalium.logic.feature.e2ei

actual interface CertificateStatusChecker {
actual fun status(notAfterTimestamp: Long): CertificateStatus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why we need to pass the time? how is not the current system time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are getting current time in CertificateStatusChecker implementation and we compare it with this passed one to know if it's expired or not

class PemCertificateDecoderTest {

@Test
fun givenAValidCertificate_whenDecodingIt_thenReturnCertificateObject() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: can you add an actual comparison here on the data you expect? based on the PEM string you passed.

Copy link
Contributor

@mchenani mchenani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍, added some other questions and suggestions.

@ohassine ohassine added this pull request to the merge queue Oct 25, 2023
Merged via the queue into develop with commit 290418d Oct 25, 2023
15 checks passed
@ohassine ohassine deleted the get_e2ei_certificate_usecase branch October 25, 2023 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants