public IActionResult Login(
            string loginClient, string clientId, string clientSecret
            )
        {
            AccessTokenResponse Result = VisualInspection.Authorize(clientId, clientSecret);

            ViewData["HttpResponse"]  = "Status code: " + (int)Result.HttpResponse.StatusCode + " " + Result.HttpResponse.StatusCode;
            ViewData["StringMessage"] = Result.HttpResponse.Content;
            ViewBag.BearerAvailable   = VisualInspection.IsAuthorized;

            return(Index());
        }
Esempio n. 2
0
        public IActionResult Login(
            string loginClient, string clientId, string clientSecret
            )
        {
            AccessTokenResponse response = hacarusVisualInspection.Authorize(clientId, clientSecret);

            if (response.errors == null)
            {
                bearer = response.data.access_token;
            }

            ViewData["HttpResponse"]  = "Status code: " + (int)response.httpResponse.StatusCode + " " + response.httpResponse.StatusCode;
            ViewData["StringMessage"] = hacarusVisualInspection.StringMessage;
            ViewBag.BearerAvailable   = !string.IsNullOrEmpty(bearer);

            return(Index());
        }
Esempio n. 3
0
        public void FailedClientID()
        {
            Console.WriteLine("FailedClientID Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeFailedClientID.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.Unauthorized, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("InvalidClientId", "ValidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Unauthorized));
            Assert.IsTrue(Response.Errors.Title.Equals("Cannot find client information"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Unauthorized));
            Console.WriteLine("FailedClientID End");
        }
Esempio n. 4
0
        public void Success()
        {
            Console.WriteLine("Success Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeSuccess.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.OK, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("ValidClientId", "ValidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Data);
            Assert.IsNull(Response.Errors);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.OK));
            Assert.IsTrue(Response.Data.AccessToken.Equals("GeneratedAccessToken"));
            Assert.IsTrue(Response.Data.Expires.Equals(2592000));
            Console.WriteLine("Success End");
        }
Esempio n. 5
0
        public void FailedClientSecret()
        {
            Console.WriteLine("FailedClientSecret Start");
            var JsonString = File.ReadAllText("../../../Files/AuthorizeFailedClientSecret.txt");
            var Client     = MockGenerator.MockRestClient <AccessTokenResponse>(HttpStatusCode.Unauthorized, JsonString);
            HacarusVisualInspection VisualInspection = new HacarusVisualInspection(Client);
            AccessTokenResponse     Response         = VisualInspection.Authorize("ValidClientId", "InvalidClientSecret");

            Assert.IsNotNull(Response);
            Assert.IsNotNull(Response.HttpResponse);
            Assert.IsNotNull(Response.Errors);
            Assert.IsNull(Response.Data);
            Assert.IsTrue(Response.HttpResponse.StatusCode.Equals(HttpStatusCode.Unauthorized));
            Assert.IsTrue(Response.Errors.Title.Equals("Client id and secret mismatch"));
            Assert.IsTrue(Response.Errors.Source.Pointer.Equals("/api/auth/token"));
            Assert.IsTrue(Response.Errors.Status.Equals((int)HttpStatusCode.Unauthorized));
            Console.WriteLine("FailedClientSecret End");
        }