Example #1
0
        public void ItCanCreateAValidOAuthUriForTheEndUser()
        {
            var httpMessageHandler = new Mock <HttpMessageHandler>();

            using var client = new HttpClient(httpMessageHandler.Object)
                  {
                      BaseAddress = new Uri("https://wubbalubbadubdub.m999/oauth/")
                  };

            var oAuthClient = new OAuth2Client(client, "clientId", "clientSecret", new Uri("monogatron:lovefinderrz"));

            Assert.Equal(
                new Uri(
                    "https://wubbalubbadubdub.m999/oauth/authorize?client_id=clientId&redirect_uri=monogatron:lovefinderrz&response_type=code"),
                oAuthClient.GetAuthenticationUrl());
        }
Example #2
0
        public void ItCanAddScopesToTheQuery()
        {
            var httpMessageHandler = new Mock <HttpMessageHandler>();

            using var client = new HttpClient(httpMessageHandler.Object)
                  {
                      BaseAddress = new Uri("https://wubbalubbadubdub.m999/oauth/")
                  };

            var oAuthClient = new OAuth2Client(client, "clientId", "clientSecret", new Uri("monogatron:lovefinderrz"));

            Assert.Equal(
                new Uri(
                    "https://wubbalubbadubdub.m999/oauth/authorize?client_id=clientId&redirect_uri=monogatron:lovefinderrz&response_type=code&scope=bank documents sales_invoices"),
                oAuthClient.GetAuthenticationUrl(new [] { MoneybirdOAuthScope.Bank, MoneybirdOAuthScope.Documents, MoneybirdOAuthScope.SalesInvoices }));
        }
Example #3
0
        public void ItCanCreateAValidOAuthUriForM2MUse()
        {
            var httpMessageHandler = new Mock <HttpMessageHandler>();

            using var client = new HttpClient(httpMessageHandler.Object)
                  {
                      BaseAddress = new Uri("https://wubbalubbadubdub.m999/oauth/")
                  };

            var oAuthClient = new OAuth2Client(client, "clientId", "clientSecret", new Uri("urn:ietf:wg:oauth:2.0:oob"));

            Assert.Equal(
                new Uri(
                    "https://wubbalubbadubdub.m999/oauth/authorize?client_id=clientId&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code"),
                oAuthClient.GetAuthenticationUrl());
        }