diff --git a/.travis.yml b/.travis.yml index f3457f8..4583b4e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,17 @@ reference: http://www.objc.io/issue-6/travis-ci.html - language: objective-c - cache: - - bundler - - cocoapods - +- bundler +- cocoapods podfile: Example/Podfile - before_install: - gem install cocoapods --no-ri --no-rdoc - gem install xcpretty --no-ri --no-rdoc - script: - xcodebuild -workspace Example/JWTDecode.xcworkspace -scheme JWTDecode -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO test | xcpretty -c ; exit ${PIPESTATUS[0]} - branches: only: - - master + - master +notifications: + slack: + secure: UIG9+o5gRYZGpRRBIB/9nFBoXvSOI3Ll63KuUMd/u/CvFpByLY0MSX5LY18v6hYqA3UNjEhOO9x1j91H7JOjbI0NYtq/7+qehUDWORaQc+NSUozKLmkIGm1M6RYayUw61J9fYpyt8AjpbGIb78i7T8ckz7dYkyhEJcGz7L+30pw= diff --git a/Example/Podfile.lock b/Example/Podfile.lock index d601dd5..923efd3 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,6 +1,6 @@ PODS: - Expecta (0.3.1) - - JWTDecode (0.2.0) + - JWTDecode (0.2.1) - Specta (0.2.1) DEPENDENCIES: @@ -14,7 +14,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Expecta: 03aabd0a89d8dea843baecb19a7fd7466a69a31d - JWTDecode: fd4bdd2324eef8cf2203c1ea1e51bf46972169e4 + JWTDecode: e94cb969a7f8e69533b0f76ff65d90238d90cb7d Specta: 9141310f46b1f68b676650ff2854e1ed0b74163a COCOAPODS: 0.34.1 diff --git a/Example/Tests/A0JWTDecoderSpec.m b/Example/Tests/A0JWTDecoderSpec.m index c5aac06..32a7672 100644 --- a/Example/Tests/A0JWTDecoderSpec.m +++ b/Example/Tests/A0JWTDecoderSpec.m @@ -23,6 +23,7 @@ #import "Specta.h" #import "A0JWTDecoder.h" +#define kJWTWithSpecialChars @"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1M2VjNjdkODI1NDIyMzE3MDAzNGYxNzciLCJlbWFpbCI6Im15ZW1haWxAZ21haWwuY29tIiwicHJvZmlsZV9waWN0dXJlIjoiaHR0cDovL2Nkbi51YnVidWJ0ZXN0ZXIuaW8vN2Q4MjU0MjIzMTcwMDM0ZjE3Ny5wbmc_dD0xNDEzNDQyMTI4OTAwIiwiaWF0IjoxNDEzNDcyNzUyfQ.WEELiFZqavfxPcnZ7vz44gbPMbEc0xeCaaS53btTYXY" NSString *A0TokenJWTCreate(NSDate *expireDate) { NSString *claims = [NSString stringWithFormat:@"{\"exp\": %f}", expireDate.timeIntervalSince1970]; @@ -136,6 +137,21 @@ }); }); + context(@"valid id_token with special chars", ^{ + + beforeEach(^{ + payload = [A0JWTDecoder payloadOfJWT:kJWTWithSpecialChars error:&error]; + }); + + specify(@"payload", ^{ + expect(payload).notTo.beEmpty(); + }); + + specify(@"no error", ^{ + expect(error).to.beNil(); + }); + }); + sharedExamplesFor(@"invalid id_token", ^(NSDictionary *data) { beforeEach(^{ @@ -150,13 +166,13 @@ specify(@"an error", ^{ expect(error).toNot.beNil(); }); - + }); - + itShouldBehaveLike(@"invalid id_token", @{ @"id_token": @"NOPARTS" }); itShouldBehaveLike(@"invalid id_token", @{ @"id_token": @"NOTENOUGH.PARTS" }); itShouldBehaveLike(@"invalid id_token", @{ @"id_token": @"HEADER.INVALIDCLAIM.SIGNATURE" }); }); }); -SpecEnd +SpecEnd \ No newline at end of file diff --git a/JWTDecode.podspec b/JWTDecode.podspec index a1f8e7d..7e1393a 100644 --- a/JWTDecode.podspec +++ b/JWTDecode.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "JWTDecode" - s.version = "0.2.0" + s.version = "0.2.1" s.summary = "A JSON Web Token decoder for iOS" s.description = <<-DESC A Simple JSON Web Token decoder for iOS that also helps you checking it's expiration date. diff --git a/Pod/Classes/A0JWTDecoder.m b/Pod/Classes/A0JWTDecoder.m index 935c584..e6c74c7 100644 --- a/Pod/Classes/A0JWTDecoder.m +++ b/Pod/Classes/A0JWTDecoder.m @@ -61,6 +61,9 @@ + (NSDictionary *)payloadOfJWT:(NSString *)jwt error:(NSError *__autoreleasing * NSInteger requiredLength = (4 * ceil((double)claimsLength / 4.0)); NSInteger paddingCount = requiredLength - claimsLength; + claimsBase64 = [claimsBase64 stringByReplacingOccurrencesOfString:@"-" withString:@"+"]; + claimsBase64 = [claimsBase64 stringByReplacingOccurrencesOfString:@"_" withString:@"/"]; + if (paddingCount > 0) { NSString *padding = [[NSString string] stringByPaddingToLength:paddingCount