mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-25 12:17:22 +00:00
Unify our Base64 utilities.
This commit is contained in:
committed by
Cody Henthorne
parent
e636e38ba1
commit
4fe6d79fff
@@ -7,9 +7,9 @@ import org.hamcrest.Matchers.`is`
|
||||
import org.junit.Test
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.mock
|
||||
import org.signal.core.util.Base64
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context
|
||||
import org.thoughtcrime.securesms.groups.v2.ChangeBuilder
|
||||
import org.thoughtcrime.securesms.util.Base64
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI
|
||||
import org.whispersystems.signalservice.internal.push.GroupContextV2
|
||||
import java.util.Random
|
||||
|
||||
@@ -3,10 +3,10 @@ package org.thoughtcrime.securesms.groups.v2;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.signal.core.util.Base64;
|
||||
import org.signal.libsignal.zkgroup.InvalidInputException;
|
||||
import org.signal.storageservice.protos.groups.GroupInviteLink;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.util.Base64UrlSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -98,13 +98,13 @@ public final class GroupInviteLinkUrl_InvalidGroupLinkException_Test {
|
||||
private static String createEncodedProtobuf(@NonNull byte[] groupMasterKey,
|
||||
@NonNull byte[] passwordBytes)
|
||||
{
|
||||
return Base64UrlSafe.encodeBytesWithoutPadding(new GroupInviteLink.Builder()
|
||||
.v1Contents(new GroupInviteLink.GroupInviteLinkContentsV1.Builder()
|
||||
.groupMasterKey(ByteString.of(groupMasterKey))
|
||||
.inviteLinkPassword(ByteString.of(passwordBytes))
|
||||
.build())
|
||||
.build()
|
||||
.encode());
|
||||
return Base64.encodeUrlSafeWithoutPadding(new GroupInviteLink.Builder()
|
||||
.v1Contents(new GroupInviteLink.GroupInviteLinkContentsV1.Builder()
|
||||
.groupMasterKey(ByteString.of(groupMasterKey))
|
||||
.inviteLinkPassword(ByteString.of(passwordBytes))
|
||||
.build())
|
||||
.build()
|
||||
.encode());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.verify
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import org.signal.core.util.Base64
|
||||
import org.signal.core.util.getParcelableExtraCompat
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.database.FakeMessageRecords
|
||||
@@ -26,7 +27,6 @@ import org.thoughtcrime.securesms.mms.ImageSlide
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority
|
||||
import org.thoughtcrime.securesms.mms.SlideDeck
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.whispersystems.util.Base64
|
||||
import java.util.Optional
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@@ -74,7 +74,7 @@ class StoryContextMenuTest {
|
||||
val expected = "Hello"
|
||||
val storyRecord = FakeMessageRecords.buildMediaMmsMessageRecord(
|
||||
storyType = StoryType.TEXT_STORY_WITH_REPLIES,
|
||||
body = Base64.encodeBytes(StoryTextPost.Builder().body(expected).build().encode())
|
||||
body = Base64.encodeWithPadding(StoryTextPost.Builder().body(expected).build().encode())
|
||||
)
|
||||
|
||||
// WHEN
|
||||
@@ -93,7 +93,7 @@ class StoryContextMenuTest {
|
||||
val expected = "https://www.signal.org"
|
||||
val storyRecord = FakeMessageRecords.buildMediaMmsMessageRecord(
|
||||
storyType = StoryType.TEXT_STORY_WITH_REPLIES,
|
||||
body = Base64.encodeBytes(StoryTextPost.Builder().build().encode()),
|
||||
body = Base64.encodeWithPadding(StoryTextPost.Builder().build().encode()),
|
||||
linkPreviews = listOf(LinkPreview(expected, "", "", 0L, Optional.empty()))
|
||||
)
|
||||
|
||||
@@ -115,7 +115,7 @@ class StoryContextMenuTest {
|
||||
val expected = "$text $url"
|
||||
val storyRecord = FakeMessageRecords.buildMediaMmsMessageRecord(
|
||||
storyType = StoryType.TEXT_STORY_WITH_REPLIES,
|
||||
body = Base64.encodeBytes(StoryTextPost.Builder().body(text).build().encode()),
|
||||
body = Base64.encodeWithPadding(StoryTextPost.Builder().body(text).build().encode()),
|
||||
linkPreviews = listOf(LinkPreview(url, "", "", 0L, Optional.empty()))
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user