public void TestFromAuthenticationMethod_noService()
        {
            RegistryAuthenticator registryAuthenticator =
                RegistryAuthenticator.FromAuthenticationMethod(
                    new AuthenticationHeaderValue("Bearer", "realm=\"https://somerealm\""),
                    registryEndpointRequestProperties,
                    new[] { new ProductInfoHeaderValue(new ProductHeaderValue("userAgent")) });

            Assert.AreEqual(
                new Uri("https://somerealm?service=someserver&scope=repository:someimage:scope"),
                registryAuthenticator.GetAuthenticationUrl(null, "scope"));
        }
        public void TestHandleHttpResponseException_pass()
        {
            const string authScheme   = "Bearer";
            const string authParamter = "realm=\"https://somerealm\",service=\"someservice\",scope=\"somescope\"";

            using (var mockHttpResponse = new HttpResponseMessage(HttpStatusCode.Unauthorized)
            {
                Headers =
                {
                    WwwAuthenticate =
                    {
                        new AuthenticationHeaderValue(authScheme, authParamter)
                    }
                }
            })
            {
                RegistryAuthenticator registryAuthenticator =
                    testAuthenticationMethodRetriever.HandleHttpResponse(mockHttpResponse);

                Assert.AreEqual(
                    new Uri("https://somerealm?service=someservice&scope=repository:someImageName:someScope"),
                    registryAuthenticator.GetAuthenticationUrl(null, "someScope"));
            }
        }
 public void GetAuthenticationUrl_basicAuth()
 {
     Assert.AreEqual(
         new Uri("https://somerealm?service=someservice&scope=repository:someimage:scope"),
         registryAuthenticator.GetAuthenticationUrl(null, "scope"));
 }