Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Credentials Manager Test #325

Merged
merged 6 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build-iOS-Swift-5.1:
macos:
xcode: "11.0.0"
xcode: "11.2.0"
shell: /bin/bash --login -eo pipefail
environment:
LC_ALL: en_US.UTF-8
Expand All @@ -11,9 +11,6 @@ jobs:
HOMEBREW_TEMP: ~/homebrew-temp
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- run:
name: Set Ruby Version
command: echo "ruby-2.5" > ~/.ruby-version
- checkout
- run: |
brew install swiftlint
Expand All @@ -29,12 +26,18 @@ jobs:
SCHEME: Auth0.iOS
DEVICE: iPhone 8
FASTLANE_EXPLICIT_OPEN_SIMULATOR: 2
- run: |
slather
mkdir /tmp/artifacts
cp ./fastlane/test_output/* /tmp/artifacts/
cp ./cobertura.xml /tmp/artifacts/
bash <(curl -s https://codecov.io/bash) -J Auth0 -f ./cobertura.xml
- save_cache:
key: dependency-cache
paths:
- Carthage/Build
- store_test_results:
path: fastlane/test_output
- store_artifacts:
path: /tmp/artifacts
build-iOS-Swift-5.0:
macos:
xcode: "10.3.0"
Expand All @@ -60,14 +63,10 @@ jobs:
SCHEME: Auth0.iOS
DEVICE: iPhone 8
FASTLANE_EXPLICIT_OPEN_SIMULATOR: 2
- run: |
bash <(curl -s https://codecov.io/bash) -J 'Auth0'
- save_cache:
key: dependency-cache
paths:
- Carthage/Build
- store_test_results:
path: fastlane/test_output
build-iOS-Swift-4.2:
macos:
xcode: "10.3.0"
Expand Down Expand Up @@ -98,8 +97,6 @@ jobs:
key: dependency-cache
paths:
- Carthage/Build
- store_test_results:
path: fastlane/test_output
build-iOS-Swift-4.0:
macos:
xcode: "10.3.0"
Expand Down
4 changes: 4 additions & 0 deletions .slather.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage_service: cobertura_xml
xcodeproj: ./Auth0.xcodeproj
scheme: Auth0.iOS
output_directory: ./
2 changes: 2 additions & 0 deletions Auth0.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_GENERATE_TEST_COVERAGE_FILES = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down Expand Up @@ -2181,6 +2182,7 @@
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_GENERATE_TEST_COVERAGE_FILES = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
Expand Down
9 changes: 3 additions & 6 deletions Auth0/CredentialsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,17 @@ public struct CredentialsManager {

func hasExpired(_ credentials: Credentials) -> Bool {

var hasATExpired = true
var hasIDTExpired = true

if let expiresIn = credentials.expiresIn {
if expiresIn > Date() { hasATExpired = false }
if expiresIn < Date() { return true }
}

if let token = credentials.idToken,
let tokenDecoded = decode(jwt: token),
let exp = tokenDecoded["exp"] as? Double {
if Date(timeIntervalSince1970: exp) > Date() { hasIDTExpired = false }
if Date(timeIntervalSince1970: exp) < Date() { return true }
}

return hasATExpired || hasIDTExpired
return false
}
}

Expand Down
2 changes: 1 addition & 1 deletion Auth0Tests/CredentialsManagerSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class CredentialsManagerSpec: QuickSpec {
expect(credentialsManager.hasValid()).to(beTrue())
}

fit("should not be valid when at valid and id token expired") {
it("should not be valid when at valid and id token expired") {
let credentials = Credentials(accessToken: AccessToken, tokenType: TokenType, idToken: ExpiredToken, refreshToken: nil, expiresIn: Date(timeIntervalSinceNow: ExpiresIn))
expect(credentialsManager.store(credentials: credentials)).to(beTrue())
expect(credentialsManager.hasValid()).to(beFalse())
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ source 'https://rubygems.org'

gem 'fastlane'
gem 'semantic', '~> 1.5'
gem 'slather'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ platform :ios do
device: device,
clean: true,
skip_build: true,
output_types: 'junit'
code_coverage: true
)
end

Expand Down
2 changes: 0 additions & 2 deletions fastlane/Scanfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ scheme "Auth0.iOS"
devices ["iPhone 8"]

clean true

output_types "html"