Skip to content

Commit

Permalink
Merge pull request #177 from mattrubin/develop
Browse files Browse the repository at this point in the history
Release OneTimePassword 3.1.2
  • Loading branch information
mattrubin authored Apr 23, 2018
2 parents eb5be38 + d6ea54a commit 2c091c8
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 54 deletions.
4 changes: 4 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ opt_in_rules:
- contains_over_first_not_nil
- discouraged_object_literal
- discouraged_optional_boolean
- discouraged_optional_collection
- empty_count
- empty_string
- explicit_enum_raw_value
- explicit_init
- extension_access_modifier
Expand All @@ -23,6 +25,7 @@ opt_in_rules:
- joined_default_parameter
- let_var_whitespace
- literal_expression_end_indentation
- lower_acl_than_parent
- multiline_parameters
- nimble_operator
- operator_usage_whitespace
Expand All @@ -36,6 +39,7 @@ opt_in_rules:
- sorted_first_last
- switch_case_on_newline
- unneeded_parentheses_in_closure_argument
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- yoda_condition
disabled_rules:
Expand Down
17 changes: 10 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ language: objective-c
xcode_workspace: OneTimePassword.xcworkspace
xcode_scheme: OneTimePassword (iOS)

osx_image: xcode9
osx_image: xcode9.3

env:
- RUNTIME="iOS 8.1" DEVICE="iPad 2"
- RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
- RUNTIME="iOS 9.0" DEVICE="iPhone 5s"
- RUNTIME="iOS 9.3" DEVICE="iPhone 6s"
- RUNTIME="iOS 10.0" DEVICE="iPhone SE"
- RUNTIME="iOS 10.3" DEVICE="iPhone 7 Plus"
- RUNTIME="iOS 11.0" DEVICE="iPhone X"
- RUNTIME="iOS 11.3" DEVICE="iPhone X"

# Include builds for watchOS
matrix:
include:
# Include an Xcode 9.0 build to test Swift 4.0 support
- osx_image: xcode9
env: RUNTIME="iOS 11.0" DEVICE="iPhone 8"
# Include an Xcode 9.2 build to test on iOS 8.x, because Xcode 9.3's iOS 8 simulator fails to launch
- osx_image: xcode9.2
env: RUNTIME="iOS 8.4" DEVICE="iPhone 4s"
# Include several build-only jobs for watchOS
- xcode_scheme: OneTimePassword (watchOS)
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.0" DEVICE="Apple Watch Series 3 - 38mm"
env: BUILD_ONLY="YES" RUNTIME="watchOS 4.3" DEVICE="Apple Watch Series 3 - 38mm"
- xcode_scheme: OneTimePassword (watchOS)
env: BUILD_ONLY="YES" RUNTIME="watchOS 3.2" DEVICE="Apple Watch Series 2 - 42mm"
- xcode_scheme: OneTimePassword (watchOS)
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

<!--## [In development][develop]-->

## [3.1.2][] (2018-04-23)
- Synthesize Equatable conformance when compiling with Swift 4.1. ([#173](https://github.com/mattrubin/OneTimePassword/pull/173))
- Fix a warning about deprecation of cross-module struct initializers by simplifying test cases for impossible-to-create invalid Generators. ([#174](https://github.com/mattrubin/OneTimePassword/pull/174))
- Upgrade xcconfigs for Xcode 9.3. ([#172](https://github.com/mattrubin/OneTimePassword/pull/172))
- Enable several new SwiftLint opt-in rules. ([#175](https://github.com/mattrubin/OneTimePassword/pull/175))


## [3.1.1][] (2018-03-31)
- Add support for Swift 4.1. ([#168](https://github.com/mattrubin/OneTimePassword/pull/168))
- Update build and linter settings for Xcode 9.3. ([#167](https://github.com/mattrubin/OneTimePassword/pull/167))
Expand Down Expand Up @@ -148,8 +155,9 @@ Changes between prerelease versions of OneTimePassword version 2 can be found be

## [1.0.0][] (2014-07-17)

[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.1...develop
[develop]: https://github.com/mattrubin/OneTimePassword/compare/3.1.2...develop

[3.1.2]: https://github.com/mattrubin/OneTimePassword/compare/3.1.1...3.1.2
[3.1.1]: https://github.com/mattrubin/OneTimePassword/compare/3.1...3.1.1
[3.1]: https://github.com/mattrubin/OneTimePassword/compare/3.0.1...3.1
[3.0.1]: https://github.com/mattrubin/OneTimePassword/compare/3.0...3.0.1
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.private
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Configuration for Carthage (https://github.com/Carthage/Carthage)

github "jspahrsummers/xcconfigs" ~> 0.11
github "jspahrsummers/xcconfigs" ~> 0.12
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "jspahrsummers/xcconfigs" "0.11"
github "jspahrsummers/xcconfigs" "0.12"
github "mattrubin/Base32" "xcode9"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/xcconfigs
2 changes: 1 addition & 1 deletion OneTimePassword.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "OneTimePassword"
s.version = "3.1.1"
s.version = "3.1.2"
s.summary = "A small library for generating TOTP and HOTP one-time passwords."
s.homepage = "https://github.com/mattrubin/OneTimePassword"
s.license = "MIT"
Expand Down
1 change: 0 additions & 1 deletion OneTimePassword.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@
baseConfigurationReference = C996EC2E1A74D5830076B105 /* Release.xcconfig */;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
SWIFT_VERSION = 4.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Then run `pod install` to install the latest version of the framework.

## Usage

> The [latest version][swift-4] of OneTimePassword uses Swift 4, and can be linked with Swift 3.2 projects using the Swift compiler's [compatibility mode](https://swift.org/blog/swift-4-0-released/#new-compatibility-modes). To use OneTimePassword with earlier versions of Swift, check out the [`swift-3`][swift-3] and [`swift-2.3`][swift-2.3] branches. To use OneTimePassword in an Objective-C based project, check out the [`objc` branch][objc] and the [1.x releases][releases].
> The [latest version][swift-4] of OneTimePassword compiles with Swift 4.x, and can be linked with Swift 3.2+ projects using the Swift compiler's [compatibility mode](https://swift.org/blog/swift-4-0-released/#new-compatibility-modes). To use OneTimePassword with earlier versions of Swift, check out the [`swift-3`][swift-3] and [`swift-2.3`][swift-2.3] branches. To use OneTimePassword in an Objective-C based project, check out the [`objc` branch][objc] and the [1.x releases][releases].
[swift-4]: https://github.com/mattrubin/OneTimePassword/tree/swift-4
[swift-3]: https://github.com/mattrubin/OneTimePassword/tree/swift-3
Expand Down
3 changes: 3 additions & 0 deletions Sources/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public struct Generator: Equatable {
}
}

#if swift(>=4.1)
#else
/// Compares two `Generator`s for equality.
public func == (lhs: Generator, rhs: Generator) -> Bool {
return (lhs.factor == rhs.factor)
Expand All @@ -211,6 +213,7 @@ public func == (lhs: Generator.Factor, rhs: Generator.Factor) -> Bool {
return false
}
}
#endif

// MARK: - Private

Expand Down
4 changes: 2 additions & 2 deletions Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.1</string>
<string>3.1.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.1.1</string>
<string>3.1.2</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
3 changes: 3 additions & 0 deletions Sources/PersistentToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ public struct PersistentToken: Equatable, Hashable {
}
}

#if swift(>=4.1)
#else
/// Compares two `PersistentToken`s for equality.
public func == (lhs: PersistentToken, rhs: PersistentToken) -> Bool {
return (lhs.identifier == rhs.identifier)
&& (lhs.token == rhs.token)
}
#endif
3 changes: 3 additions & 0 deletions Sources/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ public struct Token: Equatable {
}
}

#if swift(>=4.1)
#else
/// Compares two `Token`s for equality.
public func == (lhs: Token, rhs: Token) -> Bool {
return (lhs.name == rhs.name)
&& (lhs.issuer == rhs.issuer)
&& (lhs.generator == rhs.generator)
}
#endif
46 changes: 8 additions & 38 deletions Tests/GeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,35 +174,17 @@ class GeneratorTests: XCTestCase {
}

func testPasswordWithInvalidPeriod() {
let generator = Generator(unvalidatedFactor: .timer(period: 0))
let time = Date(timeIntervalSince1970: 100)

do {
_ = try generator.password(at: time)
} catch Generator.Error.invalidPeriod {
// This is the expected type of error
return
} catch {
XCTFail("passwordAtTime(\(time)) threw an unexpected type of error: \(error))")
return
}
XCTFail("passwordAtTime(\(time)) should throw an error)")
// It should not be possible to try to get a password from a generator with an invalid period, because the
// generator initializer should fail when given an invalid period.
let generator = Generator(factor: .timer(period: 0), secret: Data(), algorithm: .sha1, digits: 8)
XCTAssertNil(generator)
}

func testPasswordWithInvalidDigits() {
let generator = Generator(unvalidatedDigits: 3)
let time = Date(timeIntervalSince1970: 100)

do {
_ = try generator.password(at: time)
} catch Generator.Error.invalidDigits {
// This is the expected type of error
return
} catch {
XCTFail("passwordAtTime(\(time)) threw an unexpected type of error: \(error))")
return
}
XCTFail("passwordAtTime(\(time)) should throw an error)")
// It should not be possible to try to get a password from a generator with an invalid digit count, because the
// generator initializer should fail when given an invalid digit count.
let generator = Generator(factor: .timer(period: 30), secret: Data(), algorithm: .sha1, digits: 3)
XCTAssertNil(generator)
}

// The values in this test are found in Appendix D of the HOTP RFC
Expand Down Expand Up @@ -283,15 +265,3 @@ class GeneratorTests: XCTestCase {
}
}
}

private extension Generator {
init(unvalidatedFactor factor: Factor = .timer(period: 30),
unvalidatedSecret secret: Data = Data(),
unvalidatedAlgorithm algorithm: Algorithm = .sha1,
unvalidatedDigits digits: Int = 8) {
self.factor = factor
self.secret = secret
self.algorithm = algorithm
self.digits = digits
}
}

0 comments on commit 2c091c8

Please sign in to comment.