Esempio n. 1
0
        public async Task TestUsernamePasswordAuthenticateRequestAsyncNoHttpRequest()
        {
            var provider = new UsernamePasswordAuthenticationProvider(
                AuthGlobals.DefaultClientId,
                AuthGlobals.OrganizationsTenantId,
                "FakeUsername",
                "FakePassword".ToSecureString());

            await provider.AuthenticateRequestAsync(TestGlobals.GraphResource, null);
        }
Esempio n. 2
0
        public async Task TestUsernamePasswordAuthenticateRequestAsyncCorrect()
        {
            if (TestCommon.RunningInGitHubWorkflow())
            {
                Assert.Inconclusive("Skipping live test because we're running inside a GitHub action");
            }

            var configuration = TestCommon.GetConfigurationSettings();
            var username      = configuration.GetValue <string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Username");
            var password      = configuration.GetValue <string>($"{TestGlobals.CredentialsConfigurationBasePath}:{usernamePasswordConfigurationPath}:UsernamePassword:Password");

            var provider = new UsernamePasswordAuthenticationProvider(
                AuthGlobals.DefaultClientId,
                AuthGlobals.OrganizationsTenantId,
                username,
                password.ToSecureString());

            var request = new HttpRequestMessage(HttpMethod.Get, TestGlobals.GraphMeRequest);
            await provider.AuthenticateRequestAsync(TestGlobals.GraphResource, request);

            Assert.IsNotNull(request.Headers.Authorization);
            Assert.AreEqual(request.Headers.Authorization.Scheme.ToLower(), "bearer");
        }