feat(auth): 인증 후 콘텐츠 설정과 개발용 모의 인증을 추가한다
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import Foundation
|
||||
import CoreFoundation
|
||||
|
||||
@main
|
||||
struct AuthContentSettingsCheck {
|
||||
static func main() throws {
|
||||
let receiptId = "synthetic-auth-receipt"
|
||||
let cases: [(Bool, ContentType)] = [
|
||||
(true, .ALL),
|
||||
(true, .MALE),
|
||||
(true, .FEMALE),
|
||||
(false, .ALL)
|
||||
]
|
||||
|
||||
for (isAdultContentVisible, contentType) in cases {
|
||||
let request = AuthVerifyRequest(
|
||||
receiptId: receiptId,
|
||||
isAdultContentVisible: isAdultContentVisible,
|
||||
contentType: contentType
|
||||
)
|
||||
let encoded = try JSONEncoder().encode(request)
|
||||
guard let json = try JSONSerialization.jsonObject(with: encoded) as? [String: Any],
|
||||
let encodedReceipt = json["receipt_id"] as? String,
|
||||
let encodedVisibility = json["isAdultContentVisible"] as? NSNumber,
|
||||
let encodedContentType = json["contentType"] as? String else {
|
||||
assertionFailure("Expected receipt string, visibility bool and content type string")
|
||||
return
|
||||
}
|
||||
|
||||
assert(Set(json.keys) == Set(["receipt_id", "isAdultContentVisible", "contentType"]))
|
||||
assert(encodedReceipt == receiptId)
|
||||
assert(CFGetTypeID(encodedVisibility) == CFBooleanGetTypeID())
|
||||
assert(encodedVisibility.boolValue == isAdultContentVisible)
|
||||
assert(encodedContentType == contentType.rawValue)
|
||||
}
|
||||
|
||||
print("PASS: AuthVerifyRequest exact JSON keys/types and ON ALL/MALE/FEMALE, OFF ALL (4 cases)")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user