Skip to content

Commit

Permalink
fix(pamv3): fix token in subscription session (#94)
Browse files Browse the repository at this point in the history
fix(pamv3): fix token in subscription session

Fix issue because of which access token not updated in subscription session.
  • Loading branch information
parfeon authored Jan 19, 2022
1 parent 5e6ae3c commit dbbbd10
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 7 deletions.
9 changes: 7 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
name: swift
scm: github.com/pubnub/swift
version: "5.0.0"
version: "5.0.1"
schema: 1
changelog:
- date: 2022-01-19
version: 5.0.1
changes:
- type: bug
text: "Fix issue because of which access token not updated in subscription session."
- date: 2022-01-12
version: 5.0.0
changes:
Expand Down Expand Up @@ -434,7 +439,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub
location: https://github.com/pubnub/swift/archive/refs/tags/5.0.0.zip
location: https://github.com/pubnub/swift/archive/refs/tags/5.0.1.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down
2 changes: 2 additions & 0 deletions Examples/Example-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<string>demo</string>
<key>PubNubSubscribeKey</key>
<string>demo</string>
<key>PubNubUuid</key>
<string>demo-user</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
4 changes: 2 additions & 2 deletions PubNub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.1;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand Down Expand Up @@ -2539,7 +2539,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.1;
OTHER_CFLAGS = "$(inherited)";
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited)";
Expand Down
2 changes: 1 addition & 1 deletion PubNubSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'PubNubSwift'
s.version = '5.0.0'
s.version = '5.0.1'
s.homepage = 'https://github.com/pubnub/swift'
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
s.authors = { 'PubNub, Inc.' => '[email protected]' }
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/Helpers/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public struct Constant {
}()

static let pubnubSwiftSDKVersion: String = {
"5.0.0"
"5.0.1"
}()

static let appBundleId: String = {
Expand Down
1 change: 1 addition & 0 deletions Sources/PubNub/PubNub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ extension PubNub {
/// - Parameter token: The token to add to the Token Management System.
public mutating func set(token: String) {
configuration.authToken = token
subscription.configuration.authToken = token
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/PubNub/Subscription/SubscribeSessionFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public protocol SubscriptionConfiguration: RouterConfiguration {
var requestMessageCountThreshold: UInt { get }
/// PSV2 feature to subscribe with a custom filter expression.
var filterExpression: String? { get }
/// If Access Manager (PAM) is enabled, client will use `authToken` instead of `authKey` on all requests
override var authToken: String? { get set }
}

extension SubscriptionConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PubNub/Subscription/SubscriptionSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SubscriptionSession {

public let uuid = UUID()
let longPollingSession: SessionReplaceable
let configuration: SubscriptionConfiguration
internal(set) var configuration: SubscriptionConfiguration
let sessionStream: SessionListener

/// PSV2 feature to subscribe with a custom filter expression.
Expand Down
10 changes: 10 additions & 0 deletions Tests/PubNubTests/Helpers/PAMTokenTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ extension PAMTokenTests {
pubnub.set(token: "access-token")

XCTAssertEqual(pubnub.configuration.authToken, "access-token")
XCTAssertEqual(pubnub.subscription.configuration.authToken, "access-token")
}

func testChangeToken() {
var pubnub = PubNub(configuration: config)
pubnub.set(token: "access-token")
pubnub.set(token: "access-token-updated")

XCTAssertEqual(pubnub.configuration.authToken, "access-token-updated")
XCTAssertEqual(pubnub.subscription.configuration.authToken, "access-token-updated")
}

// swiftlint:enable line_length
Expand Down

0 comments on commit dbbbd10

Please sign in to comment.