public void TestPythonCacheSerializationInterop() { var accessor = new InMemoryTokenCacheAccessor(Substitute.For <ICoreLogger>()); var s = new TokenCacheJsonSerializer(accessor); string pythonBinFilePath = ResourceHelper.GetTestResourceRelativePath("cachecompat_python.bin"); byte[] bytes = File.ReadAllBytes(pythonBinFilePath); s.Deserialize(bytes, false); Assert.AreEqual(0, accessor.GetAllAccessTokens().Count()); Assert.AreEqual(0, accessor.GetAllRefreshTokens().Count()); Assert.AreEqual(0, accessor.GetAllIdTokens().Count()); Assert.AreEqual(0, accessor.GetAllAccounts().Count()); }
public void TestMsalNet2XCacheSerializationInterop() { var accessor = new InMemoryTokenCacheAccessor(Substitute.For <ICoreLogger>()); var s = new TokenCacheDictionarySerializer(accessor); string binFilePath = ResourceHelper.GetTestResourceRelativePath("cachecompat_dotnet_dictionary.bin"); byte[] bytes = File.ReadAllBytes(binFilePath); s.Deserialize(bytes, false); Assert.AreEqual(1, accessor.GetAllAccessTokens().Count()); Assert.AreEqual(1, accessor.GetAllRefreshTokens().Count()); Assert.AreEqual(1, accessor.GetAllIdTokens().Count()); Assert.AreEqual(1, accessor.GetAllAccounts().Count()); Assert.AreEqual(0, accessor.GetAllAppMetadata().Count()); var expectedAccessTokenItem = new MsalAccessTokenCacheItem("User.Read User.ReadBasic.All profile openid email") { AdditionalFieldsJson = "{\r\n \"access_token_type\": \"Bearer\"\r\n}", Environment = "login.windows.net", HomeAccountId = "13dd2c19-84cd-416a-ae7d-49573e425619.26039cce-489d-4002-8293-5b0c5134eacb", RawClientInfo = string.Empty, ClientId = "b945c513-3946-4ecd-b179-6499803a2167", TenantId = "26039cce-489d-4002-8293-5b0c5134eacb", CachedAt = "1548803419", ExpiresOnUnixTimestamp = "1548846619", ExtendedExpiresOnUnixTimestamp = "1548846619", UserAssertionHash = string.Empty, TokenType = StorageJsonValues.TokenTypeBearer }; AssertAccessTokenCacheItemsAreEqual(expectedAccessTokenItem, accessor.GetAllAccessTokens().First()); var expectedRefreshTokenItem = new MsalRefreshTokenCacheItem { Environment = "login.windows.net", HomeAccountId = "13dd2c19-84cd-416a-ae7d-49573e425619.26039cce-489d-4002-8293-5b0c5134eacb", RawClientInfo = string.Empty, ClientId = "b945c513-3946-4ecd-b179-6499803a2167" }; AssertRefreshTokenCacheItemsAreEqual(expectedRefreshTokenItem, accessor.GetAllRefreshTokens().First()); var expectedIdTokenItem = new MsalIdTokenCacheItem { Environment = "login.windows.net", HomeAccountId = "13dd2c19-84cd-416a-ae7d-49573e425619.26039cce-489d-4002-8293-5b0c5134eacb", RawClientInfo = string.Empty, ClientId = "b945c513-3946-4ecd-b179-6499803a2167", TenantId = "26039cce-489d-4002-8293-5b0c5134eacb" }; AssertIdTokenCacheItemsAreEqual(expectedIdTokenItem, accessor.GetAllIdTokens().First()); var expectedAccountItem = new MsalAccountCacheItem { Environment = "login.windows.net", HomeAccountId = "13dd2c19-84cd-416a-ae7d-49573e425619.26039cce-489d-4002-8293-5b0c5134eacb", RawClientInfo = "eyJ1aWQiOiIxM2RkMmMxOS04NGNkLTQxNmEtYWU3ZC00OTU3M2U0MjU2MTkiLCJ1dGlkIjoiMjYwMzljY2UtNDg5ZC00MDAyLTgyOTMtNWIwYzUxMzRlYWNiIn0", PreferredUsername = "******", Name = "Abhi Test", GivenName = string.Empty, FamilyName = string.Empty, LocalAccountId = "13dd2c19-84cd-416a-ae7d-49573e425619", TenantId = "26039cce-489d-4002-8293-5b0c5134eacb" }; AssertAccountCacheItemsAreEqual(expectedAccountItem, accessor.GetAllAccounts().First()); }