Skip to content

Commit 5b3eb99

Browse files
committed
Speed up -testTokenWithURLAndSecret by removing one nested loop
1 parent bd1e73b commit 5b3eb99

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

AuthenticatorTests/OTPTokenSerializationTests.m

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,11 @@ - (void)testTokenWithURLAndSecret
144144
for (NSNumber *digitNumber in digitNumbers) {
145145
for (NSNumber *periodNumber in periodNumbers) {
146146
for (NSNumber *counterNumber in counterNumbers) {
147-
for (NSString *secondSecretString in secretStrings) {
148147
// Construct the URL
149148
NSMutableDictionary *query = [NSMutableDictionary dictionary];
150149
query[@"algorithm"] = [NSString stringForAlgorithm:[algorithmNumber unsignedIntValue]];
151150
query[@"digits"] = digitNumber;
152-
query[@"secret"] = [[[secretString dataUsingEncoding:NSASCIIStringEncoding] base32String] stringByReplacingOccurrencesOfString:@"=" withString:@""];
151+
query[@"secret"] = @"A";
153152
query[@"period"] = [periodNumber isEqual:kRandomKey] ? @(arc4random()%299 + 1) : periodNumber;
154153
query[@"counter"] = [counterNumber isEqual:kRandomKey] ? @(arc4random() + ((uint64_t)arc4random() << 32)) : counterNumber;
155154
if (![issuer isEqual:[NSNull null]])
@@ -163,7 +162,7 @@ - (void)testTokenWithURLAndSecret
163162
urlComponents.percentEncodedQuery = [query queryString];
164163

165164
// Create the token
166-
NSData *secret = [secondSecretString dataUsingEncoding:NSASCIIStringEncoding];
165+
NSData *secret = [secretString dataUsingEncoding:NSASCIIStringEncoding];
167166
OTPToken *token = [OTPToken tokenWithURL:[urlComponents URL] secret:secret];
168167

169168
// Note: [OTPToken tokenWithURL:] will return nil if the token described by the URL is invalid.
@@ -197,7 +196,6 @@ - (void)testTokenWithURLAndSecret
197196
}
198197
}
199198
}
200-
}
201199
}
202200
}
203201

0 commit comments

Comments
 (0)