forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[webview_flutter] Support for handling basic authentication requests …
…(iOS) (flutter#5455) Adds the iOS implementation for basic http authentication. This PR is part of a series of PRs that aim to close flutter#83556. The PR that contains all changes can be found at flutter/packages#4140.
- Loading branch information
1 parent
e2b5334
commit 3273017
Showing
38 changed files
with
2,366 additions
and
132 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...iew_flutter_wkwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...iew_flutter_wkwebview/example/ios/RunnerTests/FWFURLAuthenticationChallengeHostApiTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@import Flutter; | ||
@import XCTest; | ||
@import webview_flutter_wkwebview; | ||
|
||
#import <OCMock/OCMock.h> | ||
|
||
@interface FWFURLAuthenticationChallengeHostApiTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation FWFURLAuthenticationChallengeHostApiTests | ||
- (void)testFlutterApiCreate { | ||
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; | ||
FWFURLAuthenticationChallengeFlutterApiImpl *flutterApi = | ||
[[FWFURLAuthenticationChallengeFlutterApiImpl alloc] | ||
initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) | ||
instanceManager:instanceManager]; | ||
|
||
flutterApi.api = OCMClassMock([FWFNSUrlAuthenticationChallengeFlutterApi class]); | ||
|
||
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"host" | ||
port:0 | ||
protocol:nil | ||
realm:@"realm" | ||
authenticationMethod:nil]; | ||
|
||
NSURLAuthenticationChallenge *mockChallenge = OCMClassMock([NSURLAuthenticationChallenge class]); | ||
OCMStub([mockChallenge protectionSpace]).andReturn(protectionSpace); | ||
|
||
[flutterApi createWithInstance:mockChallenge | ||
protectionSpace:protectionSpace | ||
completion:^(FlutterError *error){ | ||
|
||
}]; | ||
|
||
long identifier = [instanceManager identifierWithStrongReferenceForInstance:mockChallenge]; | ||
long protectionSpaceIdentifier = | ||
[instanceManager identifierWithStrongReferenceForInstance:protectionSpace]; | ||
OCMVerify([flutterApi.api createWithIdentifier:identifier | ||
protectionSpaceIdentifier:protectionSpaceIdentifier | ||
completion:OCMOCK_ANY]); | ||
} | ||
@end |
35 changes: 35 additions & 0 deletions
35
..._flutter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFURLCredentialHostApiTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@import Flutter; | ||
@import XCTest; | ||
@import webview_flutter_wkwebview; | ||
|
||
#import <OCMock/OCMock.h> | ||
|
||
@interface FWFURLCredentialHostApiTests : XCTestCase | ||
@end | ||
|
||
@implementation FWFURLCredentialHostApiTests | ||
- (void)testHostApiCreate { | ||
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; | ||
|
||
FWFURLCredentialHostApiImpl *hostApi = [[FWFURLCredentialHostApiImpl alloc] | ||
initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) | ||
instanceManager:instanceManager]; | ||
|
||
FlutterError *error; | ||
[hostApi createWithUserWithIdentifier:0 | ||
user:@"user" | ||
password:@"password" | ||
persistence:FWFNSUrlCredentialPersistencePermanent | ||
error:&error]; | ||
XCTAssertNil(error); | ||
|
||
NSURLCredential *credential = (NSURLCredential *)[instanceManager instanceForIdentifier:0]; | ||
XCTAssertEqualObjects(credential.user, @"user"); | ||
XCTAssertEqualObjects(credential.password, @"password"); | ||
XCTAssertEqual(credential.persistence, NSURLCredentialPersistencePermanent); | ||
} | ||
@end |
43 changes: 43 additions & 0 deletions
43
...ter/webview_flutter_wkwebview/example/ios/RunnerTests/FWFURLProtectionSpaceHostApiTests.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@import Flutter; | ||
@import XCTest; | ||
@import webview_flutter_wkwebview; | ||
|
||
#import <OCMock/OCMock.h> | ||
|
||
@interface FWFURLProtectionSpaceHostApiTests : XCTestCase | ||
@end | ||
|
||
@implementation FWFURLProtectionSpaceHostApiTests | ||
- (void)testFlutterApiCreate { | ||
FWFInstanceManager *instanceManager = [[FWFInstanceManager alloc] init]; | ||
FWFURLProtectionSpaceFlutterApiImpl *flutterApi = [[FWFURLProtectionSpaceFlutterApiImpl alloc] | ||
initWithBinaryMessenger:OCMProtocolMock(@protocol(FlutterBinaryMessenger)) | ||
instanceManager:instanceManager]; | ||
|
||
flutterApi.api = OCMClassMock([FWFNSUrlProtectionSpaceFlutterApi class]); | ||
|
||
NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"host" | ||
port:0 | ||
protocol:nil | ||
realm:@"realm" | ||
authenticationMethod:nil]; | ||
[flutterApi createWithInstance:protectionSpace | ||
host:@"host" | ||
realm:@"realm" | ||
authenticationMethod:@"method" | ||
completion:^(FlutterError *error){ | ||
|
||
}]; | ||
|
||
long identifier = [instanceManager identifierWithStrongReferenceForInstance:protectionSpace]; | ||
OCMVerify([flutterApi.api createWithIdentifier:identifier | ||
host:@"host" | ||
realm:@"realm" | ||
authenticationMethod:@"method" | ||
completion:OCMOCK_ANY]); | ||
} | ||
@end |
Oops, something went wrong.