Пример #1
0
        public async Task GetSetCredentialsDoesNotReturnCredentialForRandomUrl()
        {
            var retrieveUri     = new Uri("https://example.com/");
            var credentialStore = new InMemoryCredentialStore();
            var prompts         = new AuthenticationPrompts(RuntimeContext.Default, IntPtr.Zero);

            var authentication = new Authentication(
                RuntimeContext.Default,
                new Uri("https://github.com/"),
                TokenScope.Gist,
                credentialStore,
                new Authentication.AcquireCredentialsDelegate(prompts.CredentialModalPrompt),
                new Authentication.AcquireAuthenticationCodeDelegate(prompts.AuthenticationCodeModalPrompt),
                null);

            await authentication.SetCredentials(new Uri("https://github.com/"), new Credential("haacked", string.Empty));

            Assert.Null(await authentication.GetCredentials(retrieveUri));
        }
Пример #2
0
        public async Task GetSetCredentialsNormalizesGistUrls(string writeUriString, string retrieveUriString)
        {
            var retrieveUri     = new Uri(retrieveUriString);
            var credentialStore = new InMemoryCredentialStore();
            var prompts         = new AuthenticationPrompts(RuntimeContext.Default, IntPtr.Zero);

            var authentication = new Authentication(
                RuntimeContext.Default,
                new Uri(writeUriString),
                TokenScope.Gist,
                credentialStore,
                new Authentication.AcquireCredentialsDelegate(prompts.CredentialModalPrompt),
                new Authentication.AcquireAuthenticationCodeDelegate(prompts.AuthenticationCodeModalPrompt),
                null);

            await authentication.SetCredentials(new Uri(writeUriString), new Credential("haacked", string.Empty));

            var credentials = await authentication.GetCredentials(retrieveUri);

            Assert.Equal("haacked", credentials.Username);
        }