Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Fix Credentials Manager Test (auth0#325)
Browse files Browse the repository at this point in the history
* Fix Credentials Manager Tests
* CI Tweaks
* Move to Slather for CodeCov conversion
  • Loading branch information
cocojoe authored and sam-w committed Mar 11, 2020
1 parent 57d715f commit 5b9d6f3
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
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"

0 comments on commit 5b9d6f3

Please sign in to comment.