Skip to content

Commit 4ccc4a0

Browse files
rahulbawaneAbishekh-S-KamathchetanshanbagBV
authored
Release 1.12.0 (#49)
* Add sonarqube scan worflow * Pd 177323 cdv filter (#13) * Implemented CDV filter for reviews.json * Pd 177925 seccondary ratings filter (#14) * Implemented Secondaryratings filters for reviews.json * Implemented Additional field filter for reviews.json (#15) * Implemented tag dimensions filter for reviews.json * Pd 178797 add value label cdv response (#18) Mapped "ValueLabel" response object for context data values * Pd 178686 tag statistics (#19) Implemented tagstats reuest param for reviews.json and products.json * Mapped secondary averages response objects * Implemented Secondary Rating Distribution * Refactoring keyword filter classes to maintain the parity * Allow dynamic array or variadic parameters to be passed to filter function * Release 1.10.0 * Implemented Custom Sort, Relavancy Sort, Xcode 14 fix * Update Sonarscan workflow * Q&A statistics changes for statistics.json * Release 1.11.0 * Fix for configuration errors with test case changes * Release 1.11.1 * 🐛 fixed transaction monitoring issue by adding clientId in BVAnalyticsEventTransaction (#35) * Revert ":bug: fixed transaction monitoring issue by adding clientId in BVAnalyticsEventTransaction (#35)" (#37) This reverts commit ba52da0e2d2209afe443df00ace8230bdbe8b498. * Pd 215869 bv pixel transaction event not recorded on monitoring tool (#38) * 🐛 fixed transaction monitoring issue by adding clientId in BVAnalyticsEventTransaction * 🐛 fix transaction monitoring issue by checking client key in whitelist and blacklist dictionary ✅ add separate test cases for nonPII and PII transactions event * ⚰️ removing unused code * Release 1.11.2 * Pd 217873 upgrade ios minimum deployment target (#42) * 🐛 fixed transaction monitoring issue by adding clientId in BVAnalyticsEventTransaction * 🐛 fix transaction monitoring issue by checking client key in whitelist and blacklist dictionary ✅ add separate test cases for nonPII and PII transactions event * ⚰️ removing unused code * ⚡ update minimum iOS deployment target * 🔖 Release 1.11.3 * 🐛 remove escaping for unsafe parameters value (#45) * 🔖 Release 1.11.4 * ✨ add originalProductName to BVReview.swift and originalProductName success and failure test cases in BVReviewQueryTest (#48) * Pd 219419 remove hardcoded credentials (#47) * 🎨 removed hardcoded credentials * 🎨 added valid and invalid userId as json file * 🎨 handling user id json using BVTestUsers class * 🎨 applied gitguardian changes * 🔖 Release 1.12.0 --------- Co-authored-by: Abishekh S Kamath <[email protected]> Co-authored-by: chetan shanbag <[email protected]>
1 parent 259abf9 commit 4ccc4a0

File tree

11 files changed

+162
-34
lines changed

11 files changed

+162
-34
lines changed

BVSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'BVSwift'
11-
s.version = '1.11.4'
11+
s.version = '1.12.0'
1212
s.summary = 'Simple Swift based iOS SDK to interact with the Bazaarvoice platform API.'
1313
s.description = 'The Bazaarvoice Software Development Kit (SDK) is a Swift iOS library that provides an easy way to generate REST calls to the Bazaarvoice Developer API. Using this SDK, mobile developers can quickly integrate Bazaarvoice content into their native iOS apps for iPhone and iPad on iOS 8.0 or newer.'
1414

BVSwift.xcodeproj/project.pbxproj

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@
284284
9F51CA50240CD1150043AED5 /* BVReviewHighlightsConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F51CA44240CD1150043AED5 /* BVReviewHighlightsConfiguration.swift */; };
285285
9F51CA52240CD8A80043AED5 /* BVReviewHighlightsQueryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F51CA51240CD8A80043AED5 /* BVReviewHighlightsQueryTest.swift */; };
286286
B5B31E1D20B36ABD002DBEC8 /* BVSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B5B31E1320B36ABD002DBEC8 /* BVSwift.framework */; };
287+
B736C2022ABAF76600299F42 /* userIdJSON.json in Resources */ = {isa = PBXBuildFile; fileRef = B736C2012ABAF76600299F42 /* userIdJSON.json */; };
288+
B76D94E22ADE5E5800B0BF9D /* sessionTokenJSON.json in Resources */ = {isa = PBXBuildFile; fileRef = B76D94E12ADE5E5800B0BF9D /* sessionTokenJSON.json */; };
289+
B7CBDC532ABC3BF100CBE042 /* BVTestKeys.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7CBDC522ABC3BF100CBE042 /* BVTestKeys.swift */; };
287290
/* End PBXBuildFile section */
288291

289292
/* Begin PBXContainerItemProxy section */
@@ -562,7 +565,10 @@
562565
B5B31E1320B36ABD002DBEC8 /* BVSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BVSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
563566
B5B31E1720B36ABD002DBEC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
564567
B5B31E1C20B36ABD002DBEC8 /* BVSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = BVSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
565-
B5B31E2320B36ABD002DBEC8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = BVSwiftTests/Info.plist; sourceTree = "<group>"; };
568+
B736C2012ABAF76600299F42 /* userIdJSON.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = userIdJSON.json; sourceTree = "<group>"; };
569+
B76D94E12ADE5E5800B0BF9D /* sessionTokenJSON.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = sessionTokenJSON.json; sourceTree = "<group>"; };
570+
B7CBDC512ABC3BCB00CBE042 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = ../../../Xcode/BVSwiftTests/BVSwiftTests/Info.plist; sourceTree = "<group>"; };
571+
B7CBDC522ABC3BF100CBE042 /* BVTestKeys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVTestKeys.swift; sourceTree = "<group>"; };
566572
/* End PBXFileReference section */
567573

568574
/* Begin PBXFrameworksBuildPhase section */
@@ -1061,7 +1067,7 @@
10611067
B549EEA920D04E9400ED5190 /* BVCurations */,
10621068
B53984B420D94F5F00EF77DA /* BVRecommendations */,
10631069
B5B31F2820B373D8002DBEC8 /* MockData */,
1064-
B5B31F6920B3756E002DBEC8 /* Support */,
1070+
B7CBDC502ABC3BC400CBE042 /* Support */,
10651071
);
10661072
path = BVSwiftTests;
10671073
sourceTree = "<group>";
@@ -1074,6 +1080,8 @@
10741080
98686D722407159300D67889 /* testCurationsFeedTest.json */,
10751081
98686D752407159400D67889 /* testJPEGPhotoResourceDecode.json */,
10761082
98686D762407159400D67889 /* testSyndicationSource.json */,
1083+
B736C2012ABAF76600299F42 /* userIdJSON.json */,
1084+
B76D94E12ADE5E5800B0BF9D /* sessionTokenJSON.json */,
10771085
);
10781086
path = MockData;
10791087
sourceTree = "<group>";
@@ -1142,15 +1150,6 @@
11421150
path = BVAnalytics;
11431151
sourceTree = "<group>";
11441152
};
1145-
B5B31F6920B3756E002DBEC8 /* Support */ = {
1146-
isa = PBXGroup;
1147-
children = (
1148-
B5B31E2320B36ABD002DBEC8 /* Info.plist */,
1149-
);
1150-
name = Support;
1151-
path = ../../Xcode/BVSwiftTests;
1152-
sourceTree = "<group>";
1153-
};
11541153
B5B31F6A20B375DC002DBEC8 /* Support */ = {
11551154
isa = PBXGroup;
11561155
children = (
@@ -1265,6 +1264,15 @@
12651264
path = Submission;
12661265
sourceTree = "<group>";
12671266
};
1267+
B7CBDC502ABC3BC400CBE042 /* Support */ = {
1268+
isa = PBXGroup;
1269+
children = (
1270+
B7CBDC512ABC3BCB00CBE042 /* Info.plist */,
1271+
B7CBDC522ABC3BF100CBE042 /* BVTestKeys.swift */,
1272+
);
1273+
path = Support;
1274+
sourceTree = "<group>";
1275+
};
12681276
/* End PBXGroup section */
12691277

12701278
/* Begin PBXHeadersBuildPhase section */
@@ -1375,7 +1383,9 @@
13751383
files = (
13761384
98686D772407159400D67889 /* testCurationsFeedTest.json in Resources */,
13771385
98686D7A2407159400D67889 /* testJPEGPhotoResourceDecode.json in Resources */,
1386+
B76D94E22ADE5E5800B0BF9D /* sessionTokenJSON.json in Resources */,
13781387
98686D7B2407159400D67889 /* testSyndicationSource.json in Resources */,
1388+
B736C2022ABAF76600299F42 /* userIdJSON.json in Resources */,
13791389
98686D782407159400D67889 /* ph.png in Resources */,
13801390
98686D792407159400D67889 /* skelly_android.jpg in Resources */,
13811391
);
@@ -1667,6 +1677,7 @@
16671677
98686D9124080D0900D67889 /* BVMultiProductQueryTest.swift in Sources */,
16681678
98686D6F2407153C00D67889 /* BVCurationsSubmissionTest.swift in Sources */,
16691679
422C3B212538524900080544 /* BVCommentsQueryTest.swift in Sources */,
1680+
B7CBDC532ABC3BF100CBE042 /* BVTestKeys.swift in Sources */,
16701681
98686D4B240714A000D67889 /* BVURLParameterTest.swift in Sources */,
16711682
98686D53240714D100D67889 /* BVReviewSearchQueryTest.swift in Sources */,
16721683
98686D672407151600D67889 /* BVQuestionSubmissionTest.swift in Sources */,

BVSwift/BVCommon/Configuration/BVConstants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal struct BVConstants {
1818
static let appVersionField: String = "_appVersion"
1919
static let buildNumberField: String = "_buildNumber"
2020
static let sdkVersionField: String = "_bvIosSwiftSdkVersion"
21-
static let bvSwiftSDKVersion: String = "1.11.4"
21+
static let bvSwiftSDKVersion: String = "1.12.0"
2222
}
2323

2424
internal extension Bundle {

BVSwift/BVConversations/Model/BVReview.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public struct BVReview: BVQueryable, BVSubmissionable {
9191
public let userLocation: String?
9292
public let userNickname: String?
9393
public let videos: [BVVideo]?
94-
94+
public let originalProductName: String?
95+
9596
private enum CodingKeys: String, CodingKey {
9697
case additionalFieldsDictionary = "AdditionalFields"
9798
case authorId = "AuthorId"
@@ -132,6 +133,7 @@ public struct BVReview: BVQueryable, BVSubmissionable {
132133
case userLocation = "UserLocation"
133134
case userNickname = "UserNickname"
134135
case videos = "Videos"
136+
case originalProductName = "OriginalProductName"
135137
}
136138
}
137139

@@ -183,6 +185,7 @@ extension BVReview {
183185
self.userLocation = nil
184186
self.userNickname = nil
185187
self.videos = nil
188+
self.originalProductName = nil
186189
}
187190

188191
public init(productId: String) {
@@ -228,6 +231,7 @@ extension BVReview {
228231
self.userLocation = nil
229232
self.userNickname = nil
230233
self.videos = nil
234+
self.originalProductName = nil
231235
}
232236
}
233237

BVSwift/Support/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.11.4</string>
20+
<string>1.12.0</string>
2121
<key>CFBundleVersion</key>
2222
<string>1</string>
2323
<key>NSPrincipalClass</key>

BVSwiftTests/BVConversations/Display/BVMultiProductQueryTest.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ class BVMultiProductQueryTest: XCTestCase {
8181
func testMultiProductQueryWithUserId() {
8282
let expectation =
8383
self.expectation(description: "testMultiProductQueryWithUserId")
84-
85-
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: ["product4", "product2", "product3"], locale: "en_US", userId: "test109")
84+
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: ["product4", "product2", "product3"], locale: "en_US", userId: BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.validUserId.rawValue))
8685

8786
guard let multiProductSubmission = BVMultiProductQuery(multiProduct) else {
8887
XCTFail()
@@ -155,8 +154,7 @@ class BVMultiProductQueryTest: XCTestCase {
155154
func testMultiProductQueryMissingProductsError() {
156155
let expectation =
157156
self.expectation(description: "testMultiProductQueryMissingProductsError")
158-
159-
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: [], locale: "en_US", userId: "test109")
157+
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: [], locale: "en_US", userId: BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.validUserId.rawValue))
160158

161159
guard let multiProductSubmission = BVMultiProductQuery(multiProduct) else {
162160
XCTFail()
@@ -191,8 +189,7 @@ class BVMultiProductQueryTest: XCTestCase {
191189
func testMultiProductQueryMissingLocaleError() {
192190
let expectation =
193191
self.expectation(description: "testMultiProductQueryMissingLocaleError")
194-
195-
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: ["product4", "product2", "product3"], locale: "", userId: "test109")
192+
let multiProduct: BVMultiProduct = BVMultiProduct(productIds: ["product4", "product2", "product3"], locale: "", userId: BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.validUserId.rawValue))
196193

197194
guard let multiProductSubmission = BVMultiProductQuery(multiProduct) else {
198195
XCTFail()

BVSwiftTests/BVConversations/Display/BVReviewQueryTest.swift

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ class BVReviewQueryTest: XCTestCase {
222222
XCTAssertEqual(review.authorId, "endersgame")
223223
XCTAssertEqual(review.userNickname, "endersgame")
224224
XCTAssertEqual(review.userLocation, "Charlottesville, VA")
225+
XCTAssertEqual(review.originalProductName, nil)
225226

226227
guard let proDimension: BVDimensionElement =
227228
tagDimensions.filter({ (elem: BVDimensionElement) -> Bool in
@@ -1479,4 +1480,68 @@ class BVReviewQueryTest: XCTestCase {
14791480
error, "Something went horribly wrong, request took too long.")
14801481
}
14811482
}
1483+
1484+
func testReviewQueryDisplayOriginalProductName() {
1485+
1486+
let expectation = self.expectation(description: "testReviewQueryDisplayOriginalProductName")
1487+
1488+
let reviewQuery = BVReviewQuery(productId: "data-gen-moppq9ekthfzbc6qff3bqokie", limit: 10, offset: 0)
1489+
.sort(.rating, order: .descending)
1490+
.configure(BVReviewQueryTest.incentivizedStatsConfig)
1491+
.handler { (response: BVConversationsQueryResponse<BVReview>) in
1492+
1493+
if case .failure(let error) = response {
1494+
print(error)
1495+
XCTFail()
1496+
expectation.fulfill()
1497+
return
1498+
}
1499+
1500+
guard case let .success(_, reviews) = response else {
1501+
XCTFail()
1502+
expectation.fulfill()
1503+
return
1504+
}
1505+
1506+
1507+
guard let review: BVReview = reviews.first(where: {$0.reviewId == "45570991"}),
1508+
let originalProductName = review.originalProductName else {
1509+
XCTFail()
1510+
expectation.fulfill()
1511+
return
1512+
}
1513+
1514+
XCTAssertEqual(reviews.count, 10)
1515+
XCTAssertEqual(review.rating, 5)
1516+
XCTAssertEqual(review.title, "Test test")
1517+
XCTAssertEqual(review.reviewText, "test test test test test test test test tes ttesttest")
1518+
XCTAssertEqual(review.moderationStatus, "APPROVED")
1519+
XCTAssertEqual(review.reviewId, "45570991")
1520+
XCTAssertNotNil(review.productId)
1521+
XCTAssertEqual(review.isRatingsOnly, false)
1522+
XCTAssertEqual(review.isFeatured, false)
1523+
XCTAssertEqual(review.productId, "data-gen-moppq9ekthfzbc6qff3bqokie")
1524+
XCTAssertEqual(review.authorId, "jhan23")
1525+
XCTAssertEqual(review.userNickname, "jhcontentent")
1526+
XCTAssertEqual(review.userLocation, nil)
1527+
XCTAssertEqual(originalProductName, "14K White Gold Diamond Teardrop Necklace")
1528+
1529+
expectation.fulfill()
1530+
}
1531+
1532+
guard let req = reviewQuery.request else {
1533+
XCTFail()
1534+
expectation.fulfill()
1535+
return
1536+
}
1537+
1538+
print(req)
1539+
1540+
reviewQuery.async()
1541+
1542+
self.waitForExpectations(timeout: 20) { (error) in
1543+
XCTAssertNil(
1544+
error, "Something went horribly wrong, request took too long.")
1545+
}
1546+
}
14821547
}

BVSwiftTests/BVConversations/Submission/BVProgressiveSubmissionTest.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,9 @@ class BVProgressiveSubmissionTest: XCTestCase {
188188
func testProgressiveSubmissionMissingEmailError() {
189189
let expectation =
190190
self.expectation(description: "testProgressiveSubmissionMissingEmailError")
191-
192191
var progressiveReview: BVProgressiveReview = self.buildRequest()
193192
progressiveReview.userToken = nil
194-
progressiveReview.userId = "tets109"
193+
progressiveReview.userId = BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.validUserId.rawValue)
195194

196195
guard let progressiveReviewSubmission = BVProgressiveReviewSubmission(progressiveReview) else {
197196
XCTFail()
@@ -466,7 +465,7 @@ class BVProgressiveSubmissionTest: XCTestCase {
466465
submissionFields.isRecommended = true
467466

468467
var submission = BVProgressiveReview(productId:"product10", submissionFields: submissionFields)
469-
submission.submissionSessionToken = "VcticiyaPKqkXxKeZbKRoq0a3ArcQqAObHunbMNdjOiDSSYElouJV7wHkb6nZaSLw5q8OtGFyRFyPyZAChej/RAYtPmVCleQuFiwuKub0ac="
468+
submission.submissionSessionToken = BVTestKeys().loadKeyForId(fromJSON: .sessionTokenJSON, forId: BVTestKeys.sessionTokenKeys.buildRequest.rawValue)
470469
submission.locale = "en_US"
471470
submission.userToken = "6b1549daa5df7eb481d8cf95c0d3e4d2646174653d3230323130363134267573657269643d746573743039383826456d61696c416464726573733d646576656c6f70657225343062617a616172766f6963652e636f6d26557365724e616d653d3039383874657374266d61786167653d333635"
472471
return submission
@@ -478,7 +477,6 @@ class BVProgressiveSubmissionTest: XCTestCase {
478477
}
479478

480479
func buildRequestHostedAuthSuccess() -> BVProgressiveReview {
481-
482480
self.submissionFields = BVProgressiveReviewFields()
483481
submissionFields.rating = 4
484482
submissionFields.title = "my favorite product ever!"
@@ -489,15 +487,14 @@ class BVProgressiveSubmissionTest: XCTestCase {
489487
submissionFields.hostedAuthenticationCallbackurl = "https://bazaarvoice.com"
490488

491489
var submission = BVProgressiveReview(productId:"Product1", submissionFields: submissionFields)
492-
submission.submissionSessionToken = "9y8kITDlqeFpCLH634OJJr7ErGP13y3oZ8ePKsYT/jOAITIj2GQ31eD2NX4oz74SujG3c4PTgkiMHBdF2FGvRI7qDUSM2SP8sGT3maxErGudQPMh9TGx8kc/8Dgn6Ik1"
490+
submission.submissionSessionToken = BVTestKeys().loadKeyForId(fromJSON: .sessionTokenJSON, forId: BVTestKeys.sessionTokenKeys.buildRequestHostedAuthSuccess.rawValue)
493491
submission.locale = "en_US"
494-
submission.userId = "z6amcrde52q0hppiaym3h5flpf"
492+
submission.userId = BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.validUserId.rawValue)
495493
submission.hostedAuth = true
496494
return submission
497495
}
498496

499497
func buildRequestHostedAuthFailure() -> BVProgressiveReview {
500-
501498
self.submissionFields = BVProgressiveReviewFields()
502499
submissionFields.rating = 4
503500
submissionFields.title = "my favorite product ever!"
@@ -508,14 +505,10 @@ class BVProgressiveSubmissionTest: XCTestCase {
508505
submissionFields.hostedAuthenticationCallbackurl = "https://bazaarvoice.com"
509506

510507
var submission = BVProgressiveReview(productId:"Product1", submissionFields: submissionFields)
511-
submission.submissionSessionToken = "DueNHADxCKCHad5AvUHlz6Md3kxA9aVmrVEYiJ1ln3KD9E0yC+kNJ/rAjukeSdiS9h73xtnxerVFyafTPT53nSloTr6GvV5hDaelalQ+cPB8ajya2zak2AfHwBEv5R8v"
508+
submission.submissionSessionToken = BVTestKeys().loadKeyForId(fromJSON: .sessionTokenJSON, forId: BVTestKeys.sessionTokenKeys.buildRequestHostedAuthFailure.rawValue)
512509
submission.locale = "en_US"
513-
submission.userId = "invalid"
510+
submission.userId = BVTestKeys().loadKeyForId(fromJSON: .userIdJSON, forId: BVTestKeys.userIdKeys.invalidUserId.rawValue)
514511
submission.hostedAuth = true
515512
return submission
516513
}
517-
518-
519-
520-
521514
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"buildRequest": "VcticiyaPKqkXxKeZbKRoq0a3ArcQqAObHunbMNdjOiDSSYElouJV7wHkb6nZaSLw5q8OtGFyRFyPyZAChej/RAYtPmVCleQuFiwuKub0ac=",
3+
"buildRequestHostedAuthFailure": "DueNHADxCKCHad5AvUHlz6Md3kxA9aVmrVEYiJ1ln3KD9E0yC+kNJ/rAjukeSdiS9h73xtnxerVFyafTPT53nSloTr6GvV5hDaelalQ+cPB8ajya2zak2AfHwBEv5R8v",
4+
"buildRequestHostedAuthSuccess": "9y8kITDlqeFpCLH634OJJr7ErGP13y3oZ8ePKsYT/jOAITIj2GQ31eD2NX4oz74SujG3c4PTgkiMHBdF2FGvRI7qDUSM2SP8sGT3maxErGudQPMh9TGx8kc/8Dgn6Ik1"
5+
}
6+

BVSwiftTests/MockData/userIdJSON.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"validUserId": "test109",
3+
"invalidUserId": "invalid"
4+
}

BVSwiftTests/Support/BVTestKeys.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
//
3+
// BVTestKeys.swift
4+
// BVSwift
5+
//
6+
// Copyright © 2023 Bazaarvoice. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class BVTestKeys {
12+
enum idJson: String {
13+
case userIdJSON = "userIdJSON"
14+
case sessionTokenJSON = "sessionIdJSON"
15+
}
16+
17+
enum userIdKeys: String {
18+
case validUserId = "validUserId"
19+
case invalidUserId = "invalidUserId"
20+
}
21+
22+
enum sessionTokenKeys: String {
23+
case buildRequest = "buildRequest"
24+
case buildRequestHostedAuthFailure = "buildRequestHostedAuthFailure"
25+
case buildRequestHostedAuthSuccess = "buildRequestHostedAuthSuccess"
26+
}
27+
28+
func loadKeyForId(fromJSON: idJson, forId: String) -> String {
29+
guard let resourceURL =
30+
Bundle(
31+
for: BVTestKeys.self)
32+
.url(
33+
forResource: fromJSON.rawValue,
34+
withExtension: ".json") else {
35+
return ""
36+
}
37+
do {
38+
let data = try Data(contentsOf: resourceURL, options: [])
39+
if let json = try JSONSerialization.jsonObject(with: data) as? [String : Any] {
40+
return json[forId] as? String ?? ""
41+
} else {
42+
return ""
43+
}
44+
} catch {
45+
return ""
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)