public void Setup()
        {
            this.appConfig = new AppConfig
            {
                MicrosoftAccountAppId = "12345",
                MicrosoftAccountClientSecret = "secret",
                MicrosoftAccountReturnUrl = "https://localhost/return",
                MicrosoftAccountScopes = new string[] { "scope" }
            };

            this.credentialCache = new MockCredentialCache();
            this.httpResponseMessage = new HttpResponseMessage();
            this.httpProvider = new MockHttpProvider(this.httpResponseMessage);
            this.webAuthenticationUi = new MockWebUi();
            this.serviceInfoProvider = new ServiceInfoProvider(this.webAuthenticationUi.Object);
        }
Example #2
0
        /// <summary>
        /// Gets the client.
        /// </summary>
        /// <returns></returns>
        private static async Task<IOneDriveClient> GetClient()
        {
            CredentialCache credentialCache = new CredentialCache();
            string credentials = OneDriveCloudStorageServiceSettings.Default.Credentials;

            if (!String.IsNullOrWhiteSpace(credentials))
                credentialCache.InitializeCacheFromBlob(Encoding.Default.GetBytes(credentials));

            IServiceInfoProvider serviceInfoProvider = new ServiceInfoProvider(new FormsWebAuthenticationUi())
            {
                UserSignInName = OneDriveCloudStorageServiceSettings.Default.UserId
            };

            return await OneDriveClient.GetAuthenticatedMicrosoftAccountClient(
                Util.Decrypt(OneDriveCloudStorageServiceSettings.Default.AppKey, CultureConstants.InvariantCulture.NativeName),
                RedirectUri, s_scopes, serviceInfoProvider, credentialCache).ConfigureAwait(false);
        }
 public async Task GetServiceInfo_AuthenticationProviderAlreadySet()
 {
     var mockAuthenticationProvider = new Mock<IAuthenticationProvider>().Object;
     this.serviceInfoProvider = new ServiceInfoProvider(mockAuthenticationProvider, this.webAuthenticationUi.Object);
     var serviceInfo = await this.serviceInfoProvider.GetServiceInfo(this.appConfig, this.credentialCache.Object, this.httpProvider.Object);
     
     Assert.IsFalse(serviceInfo.AuthenticationProvider is MicrosoftAccountAuthenticationProvider, "Unexpected authentication provider type.");
     Assert.AreEqual(mockAuthenticationProvider, serviceInfo.AuthenticationProvider, "Unexpected authentication provider set.");
 }