Example #1
0
        public void Login_context_test()
        {
            if (TestUtil.IgnoreCertificate)
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
            }
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;

            var client = TestUtil.GetClient();
            var authEndpoint = client.Info.GetInfo().Result.AuthorizationEndpoint;
            var authUri = new Uri(authEndpoint.TrimEnd('/') + "/oauth/token");


            UAAClient uaaClient = new UAAClient(authUri);

            var context = uaaClient.Login(credentials).Result;

            Assert.IsTrue(context.IsLoggedIn);
            Assert.AreEqual(context.Uri, authUri);
            Assert.IsNotNull(context.Token.AccessToken);
            Assert.IsNotNull(context.Token.RefreshToken);
            Assert.AreEqual(TestUtil.User, context.Token.UserName);
            Assert.IsNotNull(context.Token.UserGuid);
            Assert.IsFalse(context.Token.IsExpired);
            Assert.IsTrue(context.Token.Expires > DateTime.Now);

        }
Example #2
0
        public void Login_refresh_token_test()
        {
            if (TestUtil.IgnoreCertificate)
            {
                System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
            }
            CloudCredentials credentials = new CloudCredentials();
            credentials.User = TestUtil.User;
            credentials.Password = TestUtil.Password;

            var client = TestUtil.GetClient();
            var authEndpoint = client.Info.GetInfo().Result.AuthorizationEndpoint;
            var authUri = new Uri(authEndpoint.TrimEnd('/') + "/oauth/token");


            UAAClient uaaClient = new UAAClient(authUri);

            var context = uaaClient.Login(credentials).Result;

            client.Login(context.Token.RefreshToken).Wait();

            client.Buildpacks.ListAllBuildpacks().Wait();
        }