Skip to content

Do not continue with fetch if we do not get a valid IID. #4745

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
Feb 3, 2020

Conversation

dmandar
Copy link
Contributor

@dmandar dmandar commented Jan 24, 2020

Fixes #4622

Copy link
Contributor

@maksymmalyhin maksymmalyhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM. Couple minor comments for tests from me.

_checkCompletionTimeout = 1.0;

// Always remove the database at the start of testing.
_DBPath = [RCNTestUtilities remoteConfigPathForTestDatabase];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would prefer having separate helper methods for the setup operations as it looks more readable to me. Maybe even move some into RCNTestUtilities ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will raincheck on this one. Some of the setup is particular to this file and will need to spend some time for a good generic option to pull this into RCNTestUtilities.

// Always remove the database at the start of testing.
_DBPath = [RCNTestUtilities remoteConfigPathForTestDatabase];
id classMock = OCMClassMock([RCNConfigDBManager class]);
OCMStub([classMock remoteConfigPathForDatabase]).andReturn(_DBPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to stop mocking the class at the end of the test to avoid interference with other tests? If so classMock should be stored to an ivar and taken care in tearDown method.

The same for similar mocks below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

.andReturn(_userDefaults);

RCNConfigContent *configContent = [[RCNConfigContent alloc] initWithDBManager:_DBManager];
_configInstances = [[NSMutableArray alloc] initWithCapacity:3];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use RCNTestRCNumTotalInstances instead of 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// Test for each RC FIRApp, namespace instance.
for (int i = 0; i < RCNTestRCNumTotalInstances; i++) {
// Set the token as nil.
[self mockInstanceIDMethodForTokenAndIdentity:nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like it should be out of the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

XCTAssertNil(error);
}];
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a test for a success case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be addressed in the other tests.

@@ -1396,7 +1396,9 @@ - (void)testSetFetchTimeoutConfigSetting {
- (void)testConfigureConfigWithValidInput {
// Configure the default app with our options and ensure the Remote Config instance is set up
// properly.
XCTAssertNoThrow([FIRApp configureWithOptions:[self firstAppOptions]]);
if (![FIRApp isDefaultAppConfigured]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the default app may be configured here? It looks cleaner to me to make sure previous tests clean up the state in tearDown and assert this condition in the tests or setUp, so the check below is performed unconditionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IID SDK's init needs a default app configured. How do i reset FIRApp state in teardown?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think [FIRApp deleteApp:] or probably better [FIRApp resetApps] should do the trick.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! done.

Copy link
Member

@paulb777 paulb777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix unit tests

@paulb777
Copy link
Member

paulb777 commented Feb 3, 2020

Since code freeze is tomorrow and RC is a dependent pod, please try to resolve the open issues and merge today.

@paulb777
Copy link
Member

paulb777 commented Feb 3, 2020

Still seeing an Xcode 11 build warning:

- WARN  | xcodebuild:  /Users/travis/build/firebase/firebase-ios-sdk/FirebaseRemoteConfig/Sources/RCNFetch.m:250:63: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
- NOTE  | xcodebuild:  /Users/travis/build/firebase/firebase-ios-sdk/FirebaseRemoteConfig/Sources/RCNFetch.m:250:63: note: treat the string as an argument to avoid this

@dmandar dmandar merged commit 3754b7e into master Feb 3, 2020
@dmandar dmandar deleted the rc-stoponiiderror branch February 3, 2020 22:56
@raymundcat
Copy link

Hi! im coming here from #4622
Wondering if you can help me out understand perhaps what was causing the crash and how did the update fix it?

@firebase firebase locked and limited conversation to collaborators Mar 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash: Dozen of crashes inside RCNFetch.m line 221 __81-[RCNConfigFetch refreshInstanceIDTokenAndFetchCheckInInfoWithCompletionHandler:]
6 participants