public CacheTestExecutor(
     IEnumerable <LabUserData> labUsers,
     CacheStorageType cacheStorageType)
 {
     _labUsers         = labUsers;
     _cacheStorageType = cacheStorageType;
 }
 public async Task TestAdalV5CacheCompatibilityAsync(
     CacheProgramType interactiveType,
     CacheProgramType silentType,
     CacheStorageType cacheStorageType)
 {
     var executor = new CacheTestExecutor(s_labUsers, cacheStorageType);
     await executor.ExecuteAsync(interactiveType, silentType, CancellationToken.None).ConfigureAwait(false);
 }
Beispiel #3
0
 public static void ConfigureUserCache(CacheStorageType cacheStorageType, TokenCache tokenCache, string adalV3CacheFileName, string unifiedCacheFileName)
 {
     s_cacheStorage       = cacheStorageType;
     AdalV3CacheFileName  = adalV3CacheFileName;
     UnifiedCacheFileName = unifiedCacheFileName;
     if (tokenCache != null)
     {
         tokenCache.SetBeforeAccess(BeforeAccessNotification);
         tokenCache.SetAfterAccess(AfterAccessNotification);
     }
 }
 public CacheTestExecutor(
     IEnumerable <LabUserData> labUsers,
     CacheProgramType firstProgram,
     CacheProgramType secondProgram,
     CacheStorageType cacheStorageType)
 {
     _labUsers         = labUsers;
     _firstProgram     = firstProgram;
     _secondProgram    = secondProgram;
     _cacheStorageType = cacheStorageType;
 }
Beispiel #5
0
        // Initializes the cache against a local file.
        // If the file is already present, it loads its content in the ADAL cache
        public FileBasedTokenCache(CacheStorageType cacheStorageType, string adalV3FilePath, string msalV2FilePath, string msalV3FilePath)
        {
            _cacheStorageType   = cacheStorageType;
            AdalV3CacheFilePath = adalV3FilePath;
            MsalV2CacheFilePath = msalV2FilePath;
            MsalV3CacheFilePath = msalV3FilePath;

            AfterAccess  = AfterAccessNotification;
            BeforeAccess = BeforeAccessNotification;

            LoadCache();
        }
        public async Task TestMsalV2CacheCompatibilityAsync(
            CacheProgramType interactiveType,
            CacheProgramType silentType,
            CacheStorageType cacheStorageType)
        {
            var executor = new CacheTestExecutor(
                interactiveType,
                silentType,
                cacheStorageType,
                expectSecondTokenFromCache: true);

            await executor.ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
        }
Beispiel #7
0
        public CacheTestExecutor(
            CacheProgramType firstProgram,
            CacheProgramType secondProgram,
            CacheStorageType cacheStorageType,
            bool expectSecondTokenFromCache = true,
            bool expectSecondTokenException = false)
        {
            _firstProgram     = firstProgram;
            _secondProgram    = secondProgram;
            _cacheStorageType = cacheStorageType;

            _expectSecondTokenFromCache = expectSecondTokenFromCache;
            _expectSecondTokenException = expectSecondTokenException;
        }
        // Initializes the cache against a local file.
        // If the file is already present, it loads its content in the ADAL cache
        public FileBasedTokenCache(CacheStorageType cacheStorageType, string adalV3FilePath, string unifiedCacheFilePath)
        {
            _cacheStorageType    = cacheStorageType;
            AdalV3CacheFilePath  = adalV3FilePath;
            UnifiedCacheFilePath = unifiedCacheFilePath;

            AfterAccess  = AfterAccessNotification;
            BeforeAccess = BeforeAccessNotification;

            lock (s_fileLock)
            {
                var cacheData = new CacheData
                {
                    AdalV3State  = CacheFileUtils.ReadFromFileIfExists(AdalV3CacheFilePath),
                    UnifiedState = CacheFileUtils.ReadFromFileIfExists(UnifiedCacheFilePath)
                };
                DeserializeAdalAndUnifiedCache(cacheData);
            }
        }
 public CacheProgram(string executablePath, string resultsFilePath, CacheStorageType cacheStorageType)
 {
     ExecutablePath   = executablePath;
     ResultsFilePath  = resultsFilePath;
     CacheStorageType = cacheStorageType;
 }
Beispiel #10
0
        public static CacheProgram CreateCacheProgram(CacheProgramType cacheProgramType, CacheStorageType cacheStorageType)
        {
            string executablePath;
            string resultsFilePath;

            switch (cacheProgramType)
            {
            case CacheProgramType.AdalV3:
                executablePath  = Path.Combine(BaseExecutablePath, "AdalV3", "CommonCache.Test.AdalV3.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "adalv3results.json");
                break;

            case CacheProgramType.AdalV4:
                executablePath  = Path.Combine(BaseExecutablePath, "AdalV4", "CommonCache.Test.AdalV4.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "adalv4results.json");
                break;

            case CacheProgramType.AdalV5:
                executablePath  = Path.Combine(BaseExecutablePath, "AdalV5", "CommonCache.Test.AdalV5.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "adalv5results.json");
                break;

            case CacheProgramType.MsalV2:
                executablePath  = Path.Combine(BaseExecutablePath, "MsalV2", "CommonCache.Test.MsalV2.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "msalv2results.json");
                break;

            case CacheProgramType.MsalV3:
                executablePath  = Path.Combine(BaseExecutablePath, "MsalV3", "CommonCache.Test.MsalV3.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "msalv3results.json");
                break;

            case CacheProgramType.MsalPython:
                executablePath  = Path.Combine(BaseExecutablePath, "MsalPython", "CommonCache.Test.MsalPython.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "msal_python_results.json");
                break;

            case CacheProgramType.MsalJava:
                executablePath  = Path.Combine(BaseExecutablePath, "MsalJava", "CommonCache.Test.MsalJava.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "msal_java_results.json");
                break;

            case CacheProgramType.MsalNode:
                executablePath  = Path.Combine(BaseExecutablePath, "MsalNode", "CommonCache.Test.MsalNode.exe");
                resultsFilePath = Path.Combine(CommonCacheTestUtils.CacheFileDirectory, "msal_node_results.json");
                break;

            default:
                throw new ArgumentException("Unknown cacheProgramType", nameof(cacheProgramType));
            }

            return(new CacheProgram(executablePath, resultsFilePath, cacheStorageType));
        }