Skip to content

Commit

Permalink
SDKS-3458 - More improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jeyanthanperiyasamy committed Nov 5, 2024
1 parent 79e9278 commit 41794d3
Show file tree
Hide file tree
Showing 19 changed files with 336 additions and 321 deletions.
2 changes: 1 addition & 1 deletion PingDavinci/PingDavinci/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ extension SuccessNode {
/// - property daVinci: The DaVinci instance.
/// - property user: The user.
/// - property session: The session.
struct UserDelegate: User, Session {
struct UserDelegate: User, Session, Sendable {
private let daVinci: DaVinci
private let user: User
private let session: Session
Expand Down
3 changes: 2 additions & 1 deletion PingDavinci/PingDavinci/module/Transform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public actor NodeTransformModule {
}
}

struct SessionResponse: Session {
struct SessionResponse: Session, Sendable {
nonisolated(unsafe)
public let json: [String: Any]

public init(json: [String: Any] = [:]) {
Expand Down
4 changes: 2 additions & 2 deletions PingLogger/PingLogger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -423,7 +423,7 @@
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_INSTALL_OBJC_HEADER = NO;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
6 changes: 4 additions & 2 deletions PingOidc/PingOidc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_STRICT_CONCURRENCY = complete;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -442,6 +443,7 @@
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_STRICT_CONCURRENCY = complete;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -477,7 +479,7 @@
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -510,7 +512,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion PingOidc/PingOidc/OidcError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import Foundation

/// enum fopr class for OIDC errors.
public enum OidcError: LocalizedError {
public enum OidcError: LocalizedError, Sendable {
case authorizeError(cause: Error? = nil, message: String? = nil)
case networkError(cause: Error? = nil, message: String? = nil)
case apiError(code: Int, message: String)
Expand Down
2 changes: 1 addition & 1 deletion PingOidc/PingOidc/OidcUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


/// Class for an OIDC User
public class OidcUser: User {
public final class OidcUser: User, @unchecked Sendable {
private var userinfo: UserInfo?
private let oidcClient: OidcClient

Expand Down
2 changes: 1 addition & 1 deletion PingOidc/PingOidc/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


/// Provides methods for token management, user information retrieval, and logout.
public protocol User {
public protocol User: Sendable {
/// Retrieves the token for the user.
/// - Returns: A `Result` object containing either the `Token` or an `OidcError`.
func token() async -> Result<Token, OidcError>
Expand Down
2 changes: 1 addition & 1 deletion PingOidc/PingOidcTests/mock/MockStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Mock<T: Codable>: Storage {
}
}

public class MockStorage<T: Codable>: StorageDelegate<T>, @unchecked Sendable {
public class MockStorage<T: Codable & Sendable>: StorageDelegate<T>, @unchecked Sendable {
public init(cacheable: Bool = false) {
super.init(delegate: Mock<T>(), cacheable: cacheable)
}
Expand Down
79 changes: 41 additions & 38 deletions PingOidc/PingOidcTests/mock/MockURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,49 @@ import Foundation
import XCTest
import PingLogger

class MockURLProtocol: URLProtocol {
public static var requestHistory: [URLRequest] = [URLRequest]()
class MockURLProtocol: URLProtocol, @unchecked Sendable {

nonisolated(unsafe)
public static var requestHistory: [URLRequest] = [URLRequest]()

nonisolated(unsafe)
static var requestHandler: ((URLRequest) throws -> (HTTPURLResponse, Data))?

static func startInterceptingRequests() {
URLProtocol.registerClass(MockURLProtocol.self)
}

static func stopInterceptingRequests() {
URLProtocol.unregisterClass(MockURLProtocol.self)
requestHistory.removeAll()
}

override class func canInit(with request: URLRequest) -> Bool {
return true
}

override class func canonicalRequest(for request: URLRequest) -> URLRequest {
return request
}

override func startLoading() {
MockURLProtocol.requestHistory.append(request)

static var requestHandler: ((URLRequest) throws -> (HTTPURLResponse, Data))?

static func startInterceptingRequests() {
URLProtocol.registerClass(MockURLProtocol.self)
guard let handler = MockURLProtocol.requestHandler else {
XCTFail("Received unexpected request with no handler set")
return
}

static func stopInterceptingRequests() {
URLProtocol.unregisterClass(MockURLProtocol.self)
requestHistory.removeAll()
do {
let (response, data) = try handler(request)
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
client?.urlProtocol(self, didLoad: data)
client?.urlProtocolDidFinishLoading(self)
} catch {
client?.urlProtocol(self, didFailWithError: error)
}
}

override func stopLoading() {

override class func canInit(with request: URLRequest) -> Bool {
return true
}

override class func canonicalRequest(for request: URLRequest) -> URLRequest {
return request
}

override func startLoading() {
MockURLProtocol.requestHistory.append(request)

guard let handler = MockURLProtocol.requestHandler else {
XCTFail("Received unexpected request with no handler set")
return
}
do {
let (response, data) = try handler(request)
client?.urlProtocol(self, didReceive: response, cacheStoragePolicy: .notAllowed)
client?.urlProtocol(self, didLoad: data)
client?.urlProtocolDidFinishLoading(self)
} catch {
client?.urlProtocol(self, didFailWithError: error)
}
}

override func stopLoading() {

}
}
}
8 changes: 4 additions & 4 deletions PingOrchestrate/PingOrchestrate.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
3A54417F2BCDF1D900385131 /* PingOrchestrate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A5441742BCDF1D900385131 /* PingOrchestrate.framework */; };
3A5441842BCDF1D900385131 /* PingOrchestrateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A5441832BCDF1D900385131 /* PingOrchestrateTests.swift */; };
3A5441852BCDF1D900385131 /* PingOrchestrate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A5441772BCDF1D900385131 /* PingOrchestrate.h */; settings = {ATTRIBUTES = (Public, ); }; };
3A6D7F392CD9636700EFEBCC /* ThreadSafeHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6D7F382CD9636100EFEBCC /* ThreadSafeHelper.swift */; };
3A6D7F392CD9636700EFEBCC /* SendableHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A6D7F382CD9636100EFEBCC /* SendableHelper.swift */; };
3A7575762C063F2A00891EC7 /* ModuleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7575752C063F2A00891EC7 /* ModuleTests.swift */; };
3A7575782C0673A100891EC7 /* ResponseTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7575772C0673A100891EC7 /* ResponseTests.swift */; };
3A75757A2C06947000891EC7 /* SharedContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A7575792C06947000891EC7 /* SharedContext.swift */; };
Expand Down Expand Up @@ -83,7 +83,7 @@
3A5441772BCDF1D900385131 /* PingOrchestrate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PingOrchestrate.h; sourceTree = "<group>"; };
3A54417E2BCDF1D900385131 /* PingOrchestrateTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PingOrchestrateTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3A5441832BCDF1D900385131 /* PingOrchestrateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PingOrchestrateTests.swift; sourceTree = "<group>"; };
3A6D7F382CD9636100EFEBCC /* ThreadSafeHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreadSafeHelper.swift; sourceTree = "<group>"; };
3A6D7F382CD9636100EFEBCC /* SendableHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendableHelper.swift; sourceTree = "<group>"; };
3A7575752C063F2A00891EC7 /* ModuleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleTests.swift; sourceTree = "<group>"; };
3A7575772C0673A100891EC7 /* ResponseTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseTests.swift; sourceTree = "<group>"; };
3A7575792C06947000891EC7 /* SharedContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharedContext.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -151,7 +151,7 @@
children = (
A5A712452CAC523B00B7DD58 /* PrivacyInfo.xcprivacy */,
3A5441772BCDF1D900385131 /* PingOrchestrate.h */,
3A6D7F382CD9636100EFEBCC /* ThreadSafeHelper.swift */,
3A6D7F382CD9636100EFEBCC /* SendableHelper.swift */,
3A203DA92BE06DFF0020C995 /* CookieModule.swift */,
A51D4CE22C62EB4B00FE09E0 /* CustomHeader.swift */,
3A203DA12BE0312A0020C995 /* HttpClient.swift */,
Expand Down Expand Up @@ -330,7 +330,7 @@
3A75757A2C06947000891EC7 /* SharedContext.swift in Sources */,
3AB1C9E92BD6410A003FCE3C /* Response.swift in Sources */,
3A203D592BD9DC600020C995 /* Request.swift in Sources */,
3A6D7F392CD9636700EFEBCC /* ThreadSafeHelper.swift in Sources */,
3A6D7F392CD9636700EFEBCC /* SendableHelper.swift in Sources */,
A51D4CE32C62EB4B00FE09E0 /* CustomHeader.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
1 change: 1 addition & 0 deletions PingOrchestrate/PingOrchestrate/CookieModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import Foundation
import PingStorage

/// Module for injecting cookies into requests.
public actor CookieModule {

public init() {}
Expand Down
15 changes: 9 additions & 6 deletions PingOrchestrate/PingOrchestrate/Node.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@


/// Protocol for actions
public protocol Action {}
public protocol Action: Sendable {}

/// Protocol for closeable resources
public protocol Closeable {
public protocol Closeable: Sendable {
func close()
}

Expand All @@ -27,7 +27,7 @@ public struct EmptyNode: Node, Sendable {

/// Represents an Failure node in the workflow.
/// - property cause: The cause of the error.
public struct FailureNode: Node, @unchecked Sendable {
public struct FailureNode: Node, Sendable {
public init(cause: any Error) {
self.cause = cause
}
Expand All @@ -39,7 +39,7 @@ public struct FailureNode: Node, @unchecked Sendable {
/// - property status: The status of the error.
/// - property input: The input for the error.
/// - property message: The message for the error.
public struct ErrorNode: Node, @unchecked Sendable {
public struct ErrorNode: Node, Sendable {
public init(status: Int? = nil,
input: [String : Any] = [:],
message: String = "") {
Expand All @@ -48,6 +48,7 @@ public struct ErrorNode: Node, @unchecked Sendable {
self.status = status
}

nonisolated(unsafe)
public let input: [String: Any]
public let message: String
public let status: Int?
Expand All @@ -56,7 +57,8 @@ public struct ErrorNode: Node, @unchecked Sendable {
/// Represents a success node in the workflow.
/// - property input: The input for the success.
/// - property session: The session for the success.
public struct SuccessNode: Node, @unchecked Sendable {
public struct SuccessNode: Node, Sendable {
nonisolated(unsafe)
public let input: [String: Any]
public let session: Session

Expand All @@ -75,6 +77,7 @@ open class ContinueNode: Node, @unchecked Sendable {
public let context: FlowContext
public let workflow: Workflow
public let input: [String: Any]

public let actions: [any Action]

public init(context: FlowContext, workflow: Workflow, input: [String: Any], actions: [any Action]) {
Expand All @@ -98,7 +101,7 @@ open class ContinueNode: Node, @unchecked Sendable {
}

/// Protocol for a Session. A Session represents a user's session in the application.
public protocol Session {
public protocol Session: Sendable {
/// Returns the value of the session as a String.
func value() -> String
}
Expand Down
Loading

0 comments on commit 41794d3

Please sign in to comment.