-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from TrustlyInc/dev-233805-implement-the-funct…
…ionality-of-being-able-to-choose-webview-or-in-app-browser-in-the-sdk [DEV-233805] implement the functionality of being able to choose webview or in app browser in the sdk
- Loading branch information
Showing
25 changed files
with
1,493 additions
and
279 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
### Description | ||
|
||
_(Insert pull request description)_ | ||
|
||
--- | ||
|
||
### Relevant Commits | ||
|
||
_(List of main updates)_ | ||
|
||
--- | ||
|
||
### Requirements | ||
|
||
_(Please check if your pull request fulfills the following requirements)_ | ||
|
||
- [ ] Changes were properly tested (attach evidence if applicable) | ||
- [ ] Repository's code-style/linting compliant | ||
|
||
--- | ||
|
||
### Evidence | ||
|
||
_(Insert any evidence related to this pull request. Leave it as **"None"** or **"Not applicable"** if you have nothing to add)_ | ||
|
||
--- | ||
|
||
### Additional Information | ||
|
||
_(Insert any additional information related to this pull request, as more context or Jira ticket. Leave it as **"None"** or **"Not applicable"** if you have nothing to add)_ |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// | ||
// EstablishDataUtilsTests.swift | ||
// TrustlySDK_Tests | ||
// | ||
// Created by Marcos Rivereto on 15/02/24. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import TrustlySDK | ||
|
||
final class EstablishDataUtilsTests: XCTestCase { | ||
|
||
var establishData:Dictionary<String, String> = [:] | ||
var urlWithParamters: String = "" | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
self.establishData = ["accessId": "A48B73F694C4C8EE6306", | ||
"customer.address.country" : "US", | ||
"customer.address.street" : "ABC Avenue", | ||
"metadata.urlScheme": "demoapp://"] | ||
|
||
self.urlWithParamters = "demoapp://?transactionId=1003151780&transactionType=1&merchantReference=g:cac73df7-52b4-47d7-89d3-9628d4cfb65e&payment.paymentProvider.type=1&requestSignature=E0rbmsl4KOORibvsHoDvfqIqlaQ%3D" | ||
|
||
} | ||
|
||
func testNormalizeDotNotation() throws { | ||
|
||
let expectedEstablishData: [String : AnyHashable] = [ | ||
"accessId": "A48B73F694C4C8EE6306", | ||
"customer" : ["address": ["country": "US", "street": "ABC Avenue"]], | ||
"metadata" : ["urlScheme": "demoapp://"] | ||
] | ||
|
||
let normalizedEstablish = EstablishDataUtils.normalizeEstablishWithDotNotation(establish: self.establishData) | ||
|
||
XCTAssertEqual(expectedEstablishData, normalizedEstablish) | ||
|
||
} | ||
// TODO: This test was commented, because for now we will not normalize the return | ||
// func testConvertUrlWithParameterToNormalizedEstablish() throws { | ||
// | ||
// let expectedEstablishData: [String : AnyHashable] = [ | ||
// "transactionId": "1003151780", | ||
// "transactionType": "1", | ||
// "merchantReference": "g:cac73df7-52b4-47d7-89d3-9628d4cfb65e", | ||
// "payment": ["paymentProvider": ["type" : "1"]], | ||
// "requestSignature": "E0rbmsl4KOORibvsHoDvfqIqlaQ%3D", | ||
// "url": self.urlWithParamters | ||
// ] | ||
// | ||
// let normalizedEstablish = EstablishDataUtils.buildEstablishFrom(urlWithParameters: self.urlWithParamters) | ||
// | ||
// XCTAssertEqual(expectedEstablishData, normalizedEstablish) | ||
// | ||
// } | ||
|
||
} |
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,34 @@ | ||
// | ||
// JsonUtilsTests.swift | ||
// TrustlySDK_Tests | ||
// | ||
// Created by Marcos Rivereto on 08/02/24. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import TrustlySDK | ||
|
||
final class JsonUtilsTests: XCTestCase { | ||
|
||
var establishData:Dictionary<String, String> = [:] | ||
|
||
override func setUp() { | ||
super.setUp() | ||
|
||
self.establishData = ["accessId": "FakeAccessId", | ||
"merchantId" : "8827389273"] | ||
|
||
} | ||
|
||
|
||
func testConvertDictionaryToJsonBase64AndJsonBase64ToDictionary() throws { | ||
|
||
let jsonStringBase64 = JSONUtils.getJsonBase64From(dictionary: self.establishData)! | ||
let newDictionary = JSONUtils.getDictionaryFrom(jsonStringBase64: jsonStringBase64)! | ||
|
||
XCTAssertEqual(newDictionary, self.establishData) | ||
|
||
} | ||
|
||
} |
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,137 @@ | ||
// | ||
// NetworkHelperTests.swift | ||
// TrustlySDK_Tests | ||
// | ||
// Created by Marcos Rivereto on 16/07/24. | ||
// Copyright © 2024 CocoaPods. All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import TrustlySDK | ||
|
||
final class NetworkHelperTests: XCTestCase { | ||
|
||
override func setUpWithError() throws { | ||
} | ||
|
||
override func tearDownWithError() throws { | ||
|
||
} | ||
|
||
func testThrowsInvalidUrlError() throws { | ||
|
||
XCTAssertThrowsError(try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "<sandbox>", | ||
localUrl: "", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
)) { error in | ||
XCTAssertEqual(error as! NetworkError, NetworkError.invalidUrl) | ||
} | ||
} | ||
|
||
func testBuildLocalEnvironment() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "local", | ||
localUrl: "192.168.0.1", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
) | ||
|
||
let expectedIsLocal = true | ||
let expectedUrl = URL(string: "http://192.168.0.1:8000/start/selectBank/widget?v=3.2.2-ios-sdk")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
func testBuildLocalHostEnvironment() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "local", | ||
localUrl: "", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
) | ||
|
||
let expectedIsLocal = true | ||
let expectedUrl = URL(string: "http://localhost:8000/start/selectBank/widget?v=3.2.2-ios-sdk")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
func testBuildLocalHostEnvironmentFrontendPort() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .setup, | ||
environment: "local", | ||
localUrl: "", | ||
paymentType: "Retrieval", | ||
build: "3.2.2", | ||
path: .mobile | ||
) | ||
|
||
let expectedIsLocal = true | ||
let expectedUrl = URL(string: "http://localhost:10000/frontend/mobile/setup")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
func testBuildDynamicEnvironment() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "dynamic", | ||
localUrl: "trustlyTest", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
) | ||
|
||
let expectedIsLocal = false | ||
let expectedUrl = URL(string: "https://trustlyTest.int.trustly.one/start/selectBank/widget?v=3.2.2-ios-sdk")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
func testBuildSandboxEnvironment() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "sandbox", | ||
localUrl: "", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
) | ||
|
||
let expectedIsLocal = false | ||
let expectedUrl = URL(string: "https://sandbox.paywithmybank.com/start/selectBank/widget?v=3.2.2-ios-sdk")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
func testBuildProductionEnvironment() throws { | ||
|
||
let environment = try buildEnvironment( | ||
resourceUrl: .widget, | ||
environment: "", | ||
localUrl: "", | ||
paymentType: "Retrieval", | ||
build: "3.2.2" | ||
) | ||
|
||
let expectedIsLocal = false | ||
let expectedUrl = URL(string: "https://paywithmybank.com/start/selectBank/widget?v=3.2.2-ios-sdk")! | ||
|
||
XCTAssertEqual(expectedIsLocal, environment.isLocal) | ||
XCTAssertEqual(expectedUrl, environment.url) | ||
} | ||
|
||
} |
Oops, something went wrong.