Skip to content

Commit

Permalink
Refactor test method naming and update BinaryParser
Browse files Browse the repository at this point in the history
This commit updates test method naming, removing underscore from the name to enhance readability and consistency. Changes were made to the "BinaryParser" where an optional "keyAccess" is now properly handled. A non-functional test case "testCreateNanoTDFWithInvalidKasMetadata" was also removed from "NanoTDFCreationTests".
  • Loading branch information
arkavo-com committed Jun 10, 2024
1 parent 25df072 commit d3e5a8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 3 additions & 2 deletions NanoTDF/BinaryParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ class BinaryParser {
print("Failed to read Embedded Policy plaintext / ciphertext")
return nil
}
// let keyAccess = policyType == .embeddedEncryptedWithPolicyKeyAccess ? readPolicyKeyAccess(bindingMode: bindingMode) : nil
// Policy Key Access
let keyAccess = policyType == .embeddedEncryptedWithPolicyKeyAccess ? readPolicyKeyAccess(bindingMode: bindingMode) : nil

return EmbeddedPolicyBody(length: plaintextCiphertext.count, body: plaintextCiphertext, keyAccess: nil)
return EmbeddedPolicyBody(length: plaintextCiphertext.count, body: plaintextCiphertext, keyAccess: keyAccess)
}

func readEccAndBindingMode() -> PolicyBindingConfig? {
Expand Down
2 changes: 1 addition & 1 deletion Tests/CryptoHelperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import XCTest
@testable import NanoTDF

final class CryptoHelperTests: XCTestCase {
func testInitializeSmallNanoTDF_Positive() throws {
func testInitializeSmallNanoTDFPositive() throws {
// Step 1: Initial Key Exchange
// Recipient Compressed Public Key
let recipientBase64 = "A2ifhGOpE0DjR4R0FPXvZ6YBOrcjayIpxwtxeXTudOts"
Expand Down
9 changes: 4 additions & 5 deletions Tests/InitializationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class InitializationTests: XCTestCase {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}

func testInitializeSmallNanoTDF_Positive() throws {
func testInitializeSmallNanoTDFPositive() throws {
let locator = ResourceLocator(protocolEnum: .http, body: "localhost:8080")
XCTAssertNotNil(locator)
let nanoTDF = initializeSmallNanoTDF(kasResourceLocator: locator!)
Expand All @@ -33,7 +33,7 @@ final class InitializationTests: XCTestCase {
XCTAssertNil(nanoTDF.signature)
}

func testInitializeSmallNanoTDF_Negative() throws {
func testInitializeSmallNanoTDFNegative() throws {
// out of spec - too small
var locator = ResourceLocator(protocolEnum: .http, body: "")
XCTAssertNil(locator)
Expand All @@ -58,17 +58,16 @@ final class InitializationTests: XCTestCase {
XCTAssertNil(header)
}

func testSmallNanoTDF_Size() throws {
func testSmallNanoTDFSize() throws {
let locator = ResourceLocator(protocolEnum: .http, body: "localhost:8080")
XCTAssertNotNil(locator)
let nanoTDF = initializeSmallNanoTDF(kasResourceLocator: locator!)
let data = nanoTDF.toData()
// TODO: use NanoTDFDecorator
print("data.count", data.count)
XCTAssertLessThan(data.count, 240)
}

func testSmallNanoTDF_Performance() throws {
func testSmallNanoTDFPerformance() throws {
// This is an example of a performance test case.
measure {
// Put the code you want to measure the time of here.
Expand Down
4 changes: 0 additions & 4 deletions Tests/NanoTDFCreationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,4 @@ class NanoTDFCreationTests: XCTestCase {
print(snanoTDF)
XCTAssertEqual(payload.length, 43)
}

func testCreateNanoTDFWithInvalidKasMetadata() {

}
}

0 comments on commit d3e5a8c

Please sign in to comment.