Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

fix null ref in tokenCache when UserInfo is absent #1607

Merged
merged 2 commits into from
Jun 3, 2019
Merged

Conversation

jennyf19
Copy link
Contributor

utest for IdToken and WriteMsalRefreshToken()

Alternative for issue 1604

utest for IdToken and WriteMsalRefreshToken()
@jennyf19 jennyf19 requested review from jmprieur and henrik-me May 30, 2019 02:19
result.Result.UserInfo.GivenName,
result.Result.UserInfo.FamilyName,
result.Result.UserInfo?.GivenName,
result.Result.UserInfo?.FamilyName,
Copy link
Contributor Author

@jennyf19 jennyf19 May 30, 2019

Choose a reason for hiding this comment

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

adding ? is the actual fix. the customer was getting a null ref because UserInfo is null here. There will no longer be a null ref here.
image
#Closed

Copy link
Contributor

@henrik-me henrik-me May 30, 2019

Choose a reason for hiding this comment

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

Is it then possible to complete the scenario? I believe the MSAL cache will now be empty and thus only when using the ADAL cache will there be any values in the cache... thus depending on how the customer persists the cache (which serializer/deserializer) this may or may not work? #Closed

Copy link
Contributor Author

@jennyf19 jennyf19 May 30, 2019

Choose a reason for hiding this comment

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

you are right. if there is no id_token, then we will exit out of writing items to the MSAL cache...see here however, i'm assuming, since this has been out for awhile, that it hasn't been very impactful, or our customers are not using the cache in that way?


In reply to: 288842460 [](ancestors = 288842460)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed the comments. lmk if you'd like to discuss anything further. thanks for the utest suggestions and improvements.


In reply to: 288855740 [](ancestors = 288855740,288842460)

// arrange
TokenCache tokenCache = new TokenCache();

var result = CreateAdalResultWrapper();
Copy link
Contributor

@henrik-me henrik-me May 30, 2019

Choose a reason for hiding this comment

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

nit: wrapper (or similar) #Closed

};
}

private void WriteMsalRefreshToken(AdalResultWrapper result, ITokenCacheAccessor tokenCacheAccessor)
Copy link
Contributor

@henrik-me henrik-me May 30, 2019

Choose a reason for hiding this comment

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

suggestion: WriteMsalRefreshTokenWithNullAsGivenNameAndFamilyName / WriteMsalRefreshTokenWithNullUserInfoValues #Closed

// assert
// IdToken present
Assert.AreEqual(tokenCache.TokenCacheAccessor.AccountCount, 1);
Assert.AreEqual(tokenCache.TokenCacheAccessor.RefreshTokenCount, 1);
Copy link
Contributor

@henrik-me henrik-me May 30, 2019

Choose a reason for hiding this comment

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

Assert.AreEqual [](start = 12, length = 15)

can it be tested that the userinfo values are null? #Closed


var result = CreateAdalResultWrapper();

result.Result.IdToken = "some-id-token";
Copy link
Contributor

@henrik-me henrik-me May 30, 2019

Choose a reason for hiding this comment

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

result.Result.IdToken = "some-id-token"; [](start = 12, length = 40)

perhaps something to be passed into the wrapper? Or another method which does this? seems like magic what you are doing here, this can be better explained with a method names elegantly imo #Resolved

@henrik-me
Copy link
Contributor

henrik-me commented May 30, 2019

I believe the added null checks should go in, have a few questions around the change more than actual comments relevance of the fix. #Resolved

@jennyf19
Copy link
Contributor Author

sure. we can sync up tomorrow.


In reply to: 497186624 [](ancestors = 497186624)

Copy link
Contributor

@henrik-me henrik-me left a comment

Choose a reason for hiding this comment

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

:shipit:

@jennyf19 jennyf19 merged commit 7bb8312 into dev Jun 3, 2019
@jennyf19 jennyf19 deleted the jennyf/nullRefFix branch June 3, 2019 23:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants