forked from ringcentral/pubnub-jtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f6c9190
commit 26f9cbb
Showing
28 changed files
with
650 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ plugins { | |
} | ||
group = 'com.pubnub' | ||
|
||
version = '5.0.0' | ||
version = '5.1.0' | ||
|
||
description = """""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/integrationTest/java/com/pubnub/api/integration/pam/GrantTokenIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.pubnub.api.integration.pam; | ||
|
||
import com.pubnub.api.PNConfiguration; | ||
import com.pubnub.api.PubNub; | ||
import com.pubnub.api.PubNubException; | ||
import com.pubnub.api.integration.util.BaseIntegrationTest; | ||
import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant; | ||
import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant; | ||
import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; | ||
import com.pubnub.api.models.consumer.access_manager.v3.PNToken; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
|
||
public class GrantTokenIT extends BaseIntegrationTest { | ||
private final PubNub pubNubUnderTest = getServer(); | ||
|
||
@Test | ||
public void happyPath() throws PubNubException { | ||
//given | ||
final int expectedTTL = 1337; | ||
final String expectedChannelResourceName = "channelResource"; | ||
final String expectedChannelPattern = "channel.*"; | ||
final String expectedChannelGroupResourceId = "channelGroup"; | ||
final String expectedChannelGroupPattern = "channelGroup.*"; | ||
|
||
//when | ||
final PNGrantTokenResult grantTokenResponse = pubNubUnderTest | ||
.grantToken() | ||
.ttl(expectedTTL) | ||
.channels(Arrays.asList(ChannelGrant.name(expectedChannelResourceName).delete(), | ||
ChannelGrant.pattern(expectedChannelPattern).write())) | ||
.channelGroups(Arrays.asList(ChannelGroupGrant.id(expectedChannelGroupResourceId).read(), | ||
ChannelGroupGrant.pattern(expectedChannelGroupPattern).manage())) | ||
.sync(); | ||
|
||
final PNToken pnToken = pubNubUnderTest.parseToken(grantTokenResponse.getToken()); | ||
|
||
//then | ||
assertEquals(expectedTTL, pnToken.getTtl()); | ||
assertEquals(new PNToken.PNResourcePermissions(false, false, false, false, true), | ||
pnToken.getResources().getChannels().get(expectedChannelResourceName)); | ||
assertEquals(new PNToken.PNResourcePermissions(false, true, false, false, false), | ||
pnToken.getResources().getChannelGroups().get(expectedChannelGroupResourceId)); | ||
assertEquals(new PNToken.PNResourcePermissions(false, false, true, false, false), | ||
pnToken.getPatterns().getChannels().get(expectedChannelPattern)); | ||
assertEquals(new PNToken.PNResourcePermissions(false, false, false, true, false), | ||
pnToken.getPatterns().getChannelGroups().get(expectedChannelGroupPattern)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.