Skip to content

Commit 3b7aa64

Browse files
authored
Deprecated grant method. (#334)
Added test to show setChannelMember behaviour when referential integrity is enabled.
1 parent 1b7fe15 commit 3b7aa64

File tree

2 files changed

+44
-0
lines changed
  • pubnub-kotlin

2 files changed

+44
-0
lines changed

pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,13 @@ actual interface PubNub : StatusEmitter, EventEmitter {
10021002
*
10031003
* It's possible to grant permissions to multiple [channelGroups] simultaneously.
10041004
*/
1005+
@Deprecated(
1006+
level = DeprecationLevel.WARNING,
1007+
message = "This function is deprecated. Use the grantToken(ttl, meta, authorizedUUID, channels, channelGroups, uuids)",
1008+
replaceWith = ReplaceWith(
1009+
"grantToken(ttl, meta, authorizedUUID, channels, channelGroups, uuids)"
1010+
)
1011+
)
10051012
fun grant(
10061013
read: Boolean = false,
10071014
write: Boolean = false,
@@ -1017,6 +1024,13 @@ actual interface PubNub : StatusEmitter, EventEmitter {
10171024
/**
10181025
* See [grant]
10191026
*/
1027+
@Deprecated(
1028+
level = DeprecationLevel.WARNING,
1029+
message = "This function is deprecated. Use the grantToken(ttl, meta, authorizedUUID, channels, channelGroups, uuids)",
1030+
replaceWith = ReplaceWith(
1031+
"grantToken(ttl, meta, authorizedUUID, channels, channelGroups, uuids)"
1032+
)
1033+
)
10201034
fun grant(
10211035
read: Boolean = false,
10221036
write: Boolean = false,

pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,36 @@ class ObjectsIntegrationTest : BaseIntegrationTest() {
567567
}
568568
}
569569

570+
@Test
571+
fun canSetChannelMemberWhenReferentialIntegrityIsEnabled() {
572+
// before calling setChannelMembers we need to set channel metadata
573+
pubnub.setChannelMetadata(
574+
channel = channel,
575+
name = randomValue(15),
576+
status = status01,
577+
type = type01,
578+
).sync()
579+
580+
// before calling setChannelMembers we need to set user metadata
581+
pubnub.setUUIDMetadata(
582+
uuid = testUserId01,
583+
name = randomValue(15),
584+
status = status01,
585+
type = type01,
586+
).sync()
587+
588+
val result: PNMemberArrayResult = pubnub.setChannelMembers(
589+
channel = channel,
590+
users = listOf(PNMember.Partial(uuidId = testUserId01, status = status01, type = type01)),
591+
include = MemberInclude(
592+
includeStatus = true,
593+
includeType = true,
594+
)
595+
).sync()
596+
597+
assertEquals(testUserId01, result.data.first().uuid.id)
598+
}
599+
570600
@Test
571601
fun testManageMember() {
572602
pubnub.setChannelMembers(

0 commit comments

Comments
 (0)