-
Notifications
You must be signed in to change notification settings - Fork 999
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
Support native redirects #783
Changes from 1 commit
c6cc44b
2cfa6e3
9bd56b1
0f0d722
5de1550
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,6 +288,7 @@ - (void)testSafariAppRedirectFlow_noNotification { | |
*/ | ||
- (void)testNativeRedirectSupportingSourceFlow_validNativeURL { | ||
STPSource *source = [STPFixtures alipaySourceWithNativeUrl]; | ||
NSURL *sourceURL = [NSURL URLWithString:source.details[@"native_url"]]; | ||
|
||
STPRedirectContext *context = [[STPRedirectContext alloc] initWithSource:source | ||
completion:^(__unused NSString *sourceID, __unused NSString *clientSecret, __unused NSError *error) { | ||
|
@@ -297,15 +298,18 @@ - (void)testNativeRedirectSupportingSourceFlow_validNativeURL { | |
|
||
id applicationMock = OCMClassMock([UIApplication class]); | ||
OCMStub([applicationMock sharedApplication]).andReturn(applicationMock); | ||
OCMStub([applicationMock openURL:[OCMArg any] | ||
options:[OCMArg any] | ||
completionHandler:([OCMArg invokeBlockWithArgs:@YES, nil])]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sweet!! |
||
|
||
id mockVC = OCMClassMock([UIViewController class]); | ||
[context startRedirectFlowFromViewController:mockVC]; | ||
|
||
OCMReject([sut startSafariViewControllerRedirectFlowFromViewController:[OCMArg any]]); | ||
OCMReject([sut startSafariAppRedirectFlow]); | ||
OCMVerify([applicationMock openURL:[OCMArg any] | ||
options:[OCMArg any] | ||
completionHandler:[OCMArg any]]); | ||
OCMVerify([applicationMock openURL:[OCMArg isEqual:sourceURL] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can just write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah it wasn't clear to me if they were the same. I thought maybe one way did |
||
options:[OCMArg isEqual:@{}] | ||
completionHandler:[OCMArg isNotNil]]); | ||
} | ||
|
||
/** | ||
|
@@ -327,13 +331,13 @@ - (void)testNativeRedirectSupportingSourceFlow_invalidNativeURL { | |
id mockVC = OCMClassMock([UIViewController class]); | ||
[context startRedirectFlowFromViewController:mockVC]; | ||
|
||
OCMVerify([sut startSafariViewControllerRedirectFlowFromViewController:[OCMArg any]]); | ||
OCMVerify([sut startSafariViewControllerRedirectFlowFromViewController:[OCMArg isEqual:mockVC]]); | ||
OCMReject([applicationMock openURL:[OCMArg any] | ||
options:[OCMArg any] | ||
completionHandler:[OCMArg any]]); | ||
OCMVerify([mockVC presentViewController:[OCMArg isKindOfClass:[SFSafariViewController class]] | ||
animated:YES | ||
completion:[OCMArg any]]); | ||
completion:[OCMArg isNil]]); | ||
} | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, do you know if this behaves differently from the new
openURL:options:completionHandler:
method? E.g. does the returned success value here always match the success value in the async completion block?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know it's always the same, it's described the same in the docs. The main difference in the new API afaict is the options and the asyncronicity.