Skip to content

Revert premature api changes #2097

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

Merged
merged 6 commits into from
Nov 19, 2018
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
6 changes: 0 additions & 6 deletions Example/DynamicLinks/App/iOS/DL-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://google.com</string>
<string>https://google.com/one</string>
<string>https://a.firebase.com/mypath</string>
</array>
</dict>
</plist>
42 changes: 14 additions & 28 deletions Example/DynamicLinks/FDLBuilderTestAppObjC/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand Down Expand Up @@ -69,22 +55,22 @@
</array>
</dict>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://mydomain.com</string>
<string>https://mydomain2.com</string>
<string>https://google.com</string>
<string>https://google.com</string>
<string>google</string>
<string>mydomain.com</string>
<string>https://mydomain</string>
<string>https://mydomain3.com</string>
<string>https://google.com/one</string>
<string>https://custom.com/one/two</string>
<string>https://custom1.com/one/</string>
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
9 changes: 4 additions & 5 deletions Example/DynamicLinks/FDLBuilderTestAppObjC/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ - (void)_initDefaultValues {
},
// The default value of domain appcode belongs to project: app-invites-qa
@{
@"id" : @"domainURIPrefix",
@"label" : @"App domainURIPrefix (required)",
@"defaultValue" : @"https://testfdl.page.link",
@"id" : @"domain",
@"label" : @"App domain (required)",
@"defaultValue" : @"testfdl.page.link",
},
// analytics params
@{
Expand Down Expand Up @@ -289,8 +289,7 @@ - (void)_initDefaultValues {
- (void)_buildFDLLink {
NSURL *link = [NSURL URLWithString:_paramValues[@"linkString"]];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link
domainURIPrefix:_paramValues[@"https://domain"]];
[FIRDynamicLinkComponents componentsWithLink:link domain:_paramValues[@"domain"]];

FIRDynamicLinkGoogleAnalyticsParameters *analyticsParams =
[FIRDynamicLinkGoogleAnalyticsParameters
Expand Down
19 changes: 0 additions & 19 deletions Example/DynamicLinks/FDLBuilderTestAppObjCTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,5 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;array&gt;
&lt;string&gt;https://mydomain.com&lt;/string&gt;
&lt;string&gt;https://mydomain2.com&lt;/string&gt;
&lt;string&gt;https://google.com&lt;/string&gt;
&lt;string&gt;https://google.com&lt;/string&gt;
&lt;string&gt;go&lt;/string&gt;
&lt;string&gt;g.co&lt;/string&gt;
&lt;string&gt;https://go&lt;/string&gt;
&lt;string&gt;https://g.co&lt;/string&gt;
&lt;string&gt;https://google.com/one&lt;/string&gt;
&lt;string&gt;https://custom.com/one/two&lt;/string&gt;
&lt;string&gt;https://custom1.com/one/&lt;/string&gt;
&lt;/array&gt;
&lt;/plist&gt;
</key>
<string></string>
</dict>
</plist>
87 changes: 21 additions & 66 deletions Example/DynamicLinks/Tests/FDLURLComponentsTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

#import <OCMock/OCMock.h>

static NSString *const kFDLURLDomain = @"https://xyz.page.link";
static NSString *const kFDLURLCustomDomain = @"https://foo.com/path";
static NSString *const kFDLURLDomain = @"xyz.page.link";

@interface FDLURLComponentsTests : XCTestCase
@end
Expand Down Expand Up @@ -462,14 +461,14 @@ - (void)testLinkOptionsParamsPropertiesSetProperly {

- (void)testFDLComponentsFactoryReturnsInstanceOfCorrectClass {
NSURL *link = [NSURL URLWithString:@"https://google.com"];
id returnValue = [FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
id returnValue = [FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];
XCTAssertTrue([returnValue isKindOfClass:[FIRDynamicLinkComponents class]]);
}

- (void)testFDLComponentsFactoryReturnsInstanceWithAllNilProperties {
NSURL *link = [NSURL URLWithString:@"https://google.com"];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
[FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];

XCTAssertNil(components.analyticsParameters);
XCTAssertNil(components.socialMetaTagParameters);
Expand All @@ -485,27 +484,11 @@ - (void)testFDLComponentsCreatesSimplestLinkCorrectly {
NSURL *link = [NSURL URLWithString:linkString];

NSString *expectedURLString =
[NSString stringWithFormat:@"%@/?link=%@", kFDLURLDomain, endcodedLinkString];
[NSString stringWithFormat:@"https://%@/?link=%@", kFDLURLDomain, endcodedLinkString];
NSURL *expectedURL = [NSURL URLWithString:expectedURLString];

FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
NSURL *actualURL = components.url;

XCTAssertEqualObjects(actualURL, expectedURL);
}

- (void)testFDLComponentsCustomDomainWithPath {
NSString *linkString = @"https://google.com";
NSString *endcodedLinkString = @"https%3A%2F%2Fgoogle%2Ecom";
NSURL *link = [NSURL URLWithString:linkString];

NSString *expectedURLString =
[NSString stringWithFormat:@"%@/?link=%@", kFDLURLCustomDomain, endcodedLinkString];
NSURL *expectedURL = [NSURL URLWithString:expectedURLString];

FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLCustomDomain];
[FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];
NSURL *actualURL = components.url;

XCTAssertEqualObjects(actualURL, expectedURL);
Expand All @@ -516,8 +499,7 @@ - (void)testFDLComponentsFailsOnMalformedDomain {
NSURL *link = [NSURL URLWithString:linkString];

FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link
domainURIPrefix:@"this is invalid domain URI Prefix"];
[FIRDynamicLinkComponents componentsWithLink:link domain:@"this is invalid domain"];

XCTAssertNil(components.url);
}
Expand Down Expand Up @@ -571,7 +553,7 @@ - (void)testFDLComponentsCreatesFullLinkCorrectly {

NSURL *link = [NSURL URLWithString:@"https://google.com"];
FIRDynamicLinkComponents *fdlComponents =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
[FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];
fdlComponents.analyticsParameters = analyticsParams;
fdlComponents.iOSParameters = iosParams;
fdlComponents.iTunesConnectParameters = itcParams;
Expand Down Expand Up @@ -660,43 +642,7 @@ - (void)testShortenURL {
XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
[components
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
NSError *_Nullable error) {
XCTAssertEqualObjects(shortURL.absoluteString, shortURLString);
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:0.1 handler:nil];

[keyProviderClassMock verify];
[keyProviderClassMock stopMocking];
[componentsClassMock verify];
[componentsClassMock stopMocking];
}

- (void)testDeprecatedMethodComponentsWithLinkForDomain {
NSString *shortURLString = @"https://xyz.page.link/abcd";

// Mock key provider
id keyProviderClassMock = OCMClassMock([FIRDynamicLinkComponentsKeyProvider class]);
[[[keyProviderClassMock expect] andReturn:@"fake-api-key"] APIKey];

id componentsClassMock = OCMClassMock([FIRDynamicLinkComponents class]);
[[componentsClassMock expect]
sendHTTPRequest:OCMOCK_ANY
completion:[OCMArg checkWithBlock:^BOOL(id obj) {
void (^completion)(NSData *_Nullable, NSError *_Nullable) = obj;
NSDictionary *JSON = @{@"shortLink" : shortURLString};
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:JSON options:0 error:0];
completion(JSONData, nil);
return YES;
}]];

XCTestExpectation *expectation = [self expectationWithDescription:@"completion called"];
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domain:@"xyz.page.link"];
[FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];
[components
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
NSError *_Nullable error) {
Expand Down Expand Up @@ -733,7 +679,7 @@ - (void)testShortenURLReturnsErrorWhenAPIKeyMissing {
[self expectationWithDescription:@"completion called with error"];
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link domainURIPrefix:kFDLURLDomain];
[FIRDynamicLinkComponents componentsWithLink:link domain:kFDLURLDomain];
[components
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
NSError *_Nullable error) {
Expand Down Expand Up @@ -768,11 +714,20 @@ - (void)testShortenURLReturnsErrorWhenDomainIsMalformed {
return YES;
}]];

XCTestExpectation *expectation =
[self expectationWithDescription:@"completion called with error"];
NSURL *link = [NSURL URLWithString:@"https://google.com/abc"];
FIRDynamicLinkComponents *components =
[FIRDynamicLinkComponents componentsWithLink:link
domainURIPrefix:@"this is invalid domain URI Prefix"];
XCTAssertNil(components);
[FIRDynamicLinkComponents componentsWithLink:link domain:@"this is invalid domain"];
[components
shortenWithCompletion:^(NSURL *_Nullable shortURL, NSArray<NSString *> *_Nullable warnings,
NSError *_Nullable error) {
XCTAssertNil(shortURL);
if (error) {
[expectation fulfill];
}
}];
[self waitForExpectationsWithTimeout:0.1 handler:nil];

[keyProviderClassMock verify];
[keyProviderClassMock stopMocking];
Expand Down
2 changes: 1 addition & 1 deletion Example/DynamicLinks/Tests/FIRDynamicLinkNetworkingTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#import <XCTest/XCTest.h>

#import <OCMock/OCMock.h>
#import "OCMock.h"

#import <GoogleUtilities/GULSwizzler.h>
#import "DynamicLinks/FIRDynamicLinkNetworking+Private.h"
Expand Down
51 changes: 0 additions & 51 deletions Example/DynamicLinks/Tests/FIRDynamicLinksTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -1015,57 +1015,6 @@ - (void)testSelfDiagnoseCompletionCalled {
[self waitForExpectationsWithTimeout:2.0 handler:nil];
}

#pragma mark - Custom domain tests
- (void)testValidCustomDomainNames {
// Entries in plist file:
// https://google.com
// https://google.com/one
// https://a.firebase.com/mypath

NSArray<NSString *> *urlStrings = @[
@"https://google.com/1", // Valid domain. Any path.
@"https://google.com/2", // Valid domain. Any path.
@"https://google.com/one", // Valid domain. Specified path.
@"https://a.firebase.com/mypath/", // Valid subdomain.
@"https://a.firebase.com/mypath/abcd/efgh", // Long path.
@"https://a.firebase.com/mypath?link=abcd&test=1", // Long path.
];

for (NSString *urlString in urlStrings) {
NSURL *url = [NSURL URLWithString:urlString];
BOOL matchesShortLinkFormat = [self.service matchesShortLinkFormat:url];

XCTAssertTrue(matchesShortLinkFormat,
@"Non-DDL domain URL matched short link format with URL: %@", url);
}
}

- (void)testInvalidCustomDomainNames {
// Entries in plist file:
// https://google.com
// https://google.com/one
// https://a.firebase.com/mypath

NSArray<NSString *> *urlStrings = @[
@"mydomain.com", // Domain not in plist. Also, no scheme.
@"http://mydomain", // Domain not in plist. No path.
@"google.com", // Valid domain. No scheme.
@"https://google.com", // Valid domain. No path.
@"http://google.com", // Valid domain. Invalid scheme.
@"https://google.co.in/abc", // Invalid domain starts with valid domain name.
@"https://firebase.com/mypath", // Invalid (sub)domain.
@"https://b.firebase.com/mypath" // Invalid subdomain.
];

for (NSString *urlString in urlStrings) {
NSURL *url = [NSURL URLWithString:urlString];
BOOL matchesShortLinkFormat = [self.service matchesShortLinkFormat:url];

XCTAssertFalse(matchesShortLinkFormat,
@"Non-DDL domain URL matched short link format with URL: %@", url);
}
}

#pragma mark - Private Helpers

- (void)removeAllFIRApps {
Expand Down
1 change: 0 additions & 1 deletion Firebase/DynamicLinks/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# v3.2.0
- Add support for creating and receiving dynamic links from custom domains. This feature is not yet available for public consumption. (#1962, #2017, #2078)
- Delete deprecated source files. (#2038)

# v3.1.1
Expand Down
Loading