|
1 | 1 | import XCTest
|
| 2 | +@testable import JWATests |
2 | 3 | @testable import JWTTests
|
3 | 4 |
|
| 5 | +extension HMACAlgorithmTests { |
| 6 | + static var allTests: [(String, (HMACAlgorithmTests) -> () throws -> Void)] { |
| 7 | + return [ |
| 8 | + ("testSHA256Name", testSHA256Name), |
| 9 | + ("testSHA384Name", testSHA384Name), |
| 10 | + ("testSHA512Name", testSHA512Name), |
| 11 | + ("testSHA256Sign", testSHA256Sign), |
| 12 | + ("testSHA384Sign", testSHA384Sign), |
| 13 | + ("testSHA512Sign", testSHA512Sign), |
| 14 | + ("testSHA256Verify", testSHA256Verify), |
| 15 | + ("testSHA384Verify", testSHA384Verify), |
| 16 | + ("testSHA512Verify", testSHA512Verify) |
| 17 | + ] |
| 18 | + } |
| 19 | +} |
4 | 20 |
|
5 |
| -extension EncodeTests { |
6 |
| - static var allTests: [(String, (EncodeTests) -> (Void) throws -> Void)] { |
| 21 | +extension NoneAlgorithmTests { |
| 22 | + static var allTests: [(String, (NoneAlgorithmTests) -> () throws -> Void)] { |
7 | 23 | return [
|
8 |
| - ("testEncodingJWT", testEncodingJWT), |
9 |
| - ("testEncodingWithBuilder", testEncodingWithBuilder), |
| 24 | + ("testName", testName), |
| 25 | + ("testSign", testSign), |
| 26 | + ("testVerify", testVerify) |
10 | 27 | ]
|
11 | 28 | }
|
12 | 29 | }
|
13 | 30 |
|
| 31 | +extension CompactJSONDecoderTests { |
| 32 | + static var allTests: [(String, (CompactJSONDecoderTests) -> () throws -> Void)] { |
| 33 | + return [ |
| 34 | + ("testDecoder", testDecoder) |
| 35 | + ] |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +extension CompactJSONEncoderTests { |
| 40 | + static var allTests: [(String, (CompactJSONEncoderTests) -> () throws -> Void)] { |
| 41 | + return [ |
| 42 | + ("testEncode", testEncode) |
| 43 | + ] |
| 44 | + } |
| 45 | +} |
| 46 | + |
14 | 47 | extension DecodeTests {
|
15 |
| - static var allTests: [(String, (DecodeTests) -> (Void) throws -> Void)] { |
| 48 | + static var allTests: [(String, (DecodeTests) -> () throws -> Void)] { |
16 | 49 | return [
|
17 | 50 | ("testDecodingValidJWT", testDecodingValidJWT),
|
18 | 51 | ("testFailsToDecodeInvalidStringWithoutThreeSegments", testFailsToDecodeInvalidStringWithoutThreeSegments),
|
@@ -40,26 +73,64 @@ extension DecodeTests {
|
40 | 73 | ("testNoneFailsWithSecretAlgorithm", testNoneFailsWithSecretAlgorithm),
|
41 | 74 | ("testMatchesAnyAlgorithm", testMatchesAnyAlgorithm),
|
42 | 75 | ("testHS384Algorithm", testHS384Algorithm),
|
43 |
| - ("testHS512Algorithm", testHS512Algorithm), |
| 76 | + ("testHS512Algorithm", testHS512Algorithm) |
44 | 77 | ]
|
45 | 78 | }
|
46 | 79 | }
|
47 | 80 |
|
| 81 | +extension IntegrationTests { |
| 82 | + static var allTests: [(String, (IntegrationTests) -> () throws -> Void)] { |
| 83 | + return [ |
| 84 | + ("testVerificationFailureWithoutLeeway", testVerificationFailureWithoutLeeway), |
| 85 | + ("testVerificationSuccessWithLeeway", testVerificationSuccessWithLeeway) |
| 86 | + ] |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +extension JWTEncodeTests { |
| 91 | + static var allTests: [(String, (JWTEncodeTests) -> () throws -> Void)] { |
| 92 | + return [ |
| 93 | + ("testEncodingJWT", testEncodingJWT), |
| 94 | + ("testEncodingWithBuilder", testEncodingWithBuilder), |
| 95 | + ("testEncodingClaimsWithHeaders", testEncodingClaimsWithHeaders) |
| 96 | + ] |
| 97 | + } |
| 98 | +} |
| 99 | + |
48 | 100 | extension PayloadTests {
|
49 |
| - static var allTests: [(String, (PayloadTests) -> (Void) throws -> Void)] { |
| 101 | + static var allTests: [(String, (PayloadTests) -> () throws -> Void)] { |
50 | 102 | return [
|
51 | 103 | ("testIssuer", testIssuer),
|
52 | 104 | ("testAudience", testAudience),
|
53 | 105 | ("testExpiration", testExpiration),
|
54 | 106 | ("testNotBefore", testNotBefore),
|
55 | 107 | ("testIssuedAt", testIssuedAt),
|
56 |
| - ("testCustomAttributes", testCustomAttributes), |
| 108 | + ("testCustomAttributes", testCustomAttributes) |
57 | 109 | ]
|
58 | 110 | }
|
59 | 111 | }
|
60 | 112 |
|
| 113 | +extension ValidationTests { |
| 114 | + static var allTests: [(String, (ValidationTests) -> () throws -> Void)] { |
| 115 | + return [ |
| 116 | + ("testClaimJustExpiredWithoutLeeway", testClaimJustExpiredWithoutLeeway), |
| 117 | + ("testClaimJustNotExpiredWithoutLeeway", testClaimJustNotExpiredWithoutLeeway), |
| 118 | + ("testNotBeforeIsImmatureSignatureWithoutLeeway", testNotBeforeIsImmatureSignatureWithoutLeeway), |
| 119 | + ("testNotBeforeIsValidWithLeeway", testNotBeforeIsValidWithLeeway), |
| 120 | + ("testIssuedAtIsInFutureWithoutLeeway", testIssuedAtIsInFutureWithoutLeeway), |
| 121 | + ("testIssuedAtIsValidWithLeeway", testIssuedAtIsValidWithLeeway) |
| 122 | + ] |
| 123 | + } |
| 124 | +} |
| 125 | + |
61 | 126 | XCTMain([
|
62 |
| - testCase(EncodeTests.allTests), |
| 127 | + testCase(HMACAlgorithmTests.allTests), |
| 128 | + testCase(NoneAlgorithmTests.allTests), |
| 129 | + testCase(CompactJSONDecoder.allTests), |
| 130 | + testCase(CompactJSONEncoder.allTests), |
63 | 131 | testCase(DecodeTests.allTests),
|
| 132 | + testCase(IntegrationTests.allTests), |
| 133 | + testCase(JWTEncodeTests.allTests), |
64 | 134 | testCase(PayloadTests.allTests),
|
| 135 | + testCase(ValidationTests.allTests) |
65 | 136 | ])
|
0 commit comments