コード例 #1
0
        public void GetAuthorizationHeader_ReturnsAccessToken()
        {
            BraintreeGateway oauthGateway = new BraintreeGateway(
                "client_id$development$integration_client_id",
                "client_secret$development$integration_client_secret"
                );

            string code = OAuthTestHelper.CreateGrant(oauthGateway, "integration_merchant_id", "read_write");

            ResultImpl <OAuthCredentials> accessTokenResult = oauthGateway.OAuth.CreateTokenFromCode(new OAuthCredentialsRequest
            {
                Code  = code,
                Scope = "read_write"
            });

            BraintreeGateway gateway            = new BraintreeGateway(accessTokenResult.Target.AccessToken);
            Configuration    oauthConfiguration = gateway.Configuration;
            BraintreeService oauthService       = new BraintreeService(oauthConfiguration);
            var headers = oauthService.GetAuthorizationHeader();

#if netcore
            Assert.AreEqual(oauthConfiguration.AccessToken, headers);
#else
            Assert.AreEqual(oauthConfiguration.AccessToken, headers.Split(' ')[1]);
#endif
        }
コード例 #2
0
        public void GetAuthorizationHeader_ReturnsCredentials()
        {
            var headers = service.GetAuthorizationHeader();

            Assert.IsNotEmpty(headers);
        }
コード例 #3
0
        public void GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys()
        {
            BraintreeService service = new BraintreeService(new Configuration(
                                                                Environment.DEVELOPMENT,
                                                                "integration_merchant_id",
                                                                "integration_public_key",
                                                                "integration_private_key"
                                                                ));

            Assert.AreEqual("Basic aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", service.GetAuthorizationHeader());
        }
コード例 #4
0
        public void GetAuthorizationHeader_ReturnsBase64EncodePublicAndPrivateKeys()
        {
            BraintreeService service = new BraintreeService(new Configuration(
                Environment.DEVELOPMENT,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            ));

#if netcore
            Assert.AreEqual("aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", service.GetAuthorizationHeader());
#else
            Assert.AreEqual("Basic aW50ZWdyYXRpb25fcHVibGljX2tleTppbnRlZ3JhdGlvbl9wcml2YXRlX2tleQ==", service.GetAuthorizationHeader());
#endif
        }