public Fixture Then_we_can_connect()
        {
            var oAuthParameters = new OAuthParameters(
                _consumer.ConsumerKey,
                new TokenKey(_consumer.ConsumerKey.Value),
                "RSA-SHA1",
                new DefaultTimestampSequence(),
                new DefaultNonceSequence(),
                string.Empty,
                "1.0"
            );

            var earl = new Uri("https://api.xero.com/api.xro/2.0/Organisation");

            var signatureBaseString =
                new SignatureBaseString(
                    new Request
                    {
                        Url = earl,
                        Verb = "GET"
                    },
                    oAuthParameters
                );

            var signature = new RsaSha1(_cert).Sign(signatureBaseString);

            oAuthParameters.SetSignature(signature);

            var header = new AuthorizationHeader(oAuthParameters, string.Empty);

            var req = (HttpWebRequest)WebRequest.Create(earl);

            req.Headers.Add("Authorization", header.Value);

            var response = TInternet.Get(req);
            const HttpStatusCode expected = HttpStatusCode.OK;
            var actual = response.StatusCode;

            return new YesNoFixture(actual == expected, "Expected [" + expected + "]. Got [" + actual + "]. And here is the body: " + response.Body, 2);
        }
        public Fixture Then_we_can_connect()
        {
            var oAuthParameters = new OAuthParameters(
                _consumer.ConsumerKey,
                new TokenKey(string.Empty),
                "HMAC-SHA1",
                new DefaultTimestampSequence(),
                new DefaultNonceSequence(),
                string.Empty,
                "1.0"
            );

            var signatureBaseString =
                new SignatureBaseString(
                    new Request {
                        Url = new Uri("https://api.twitter.com/oauth/request_token"),
                        Verb = "GET"
                    },
                    oAuthParameters
                );

            var signature = new HmacSha1().Sign(signatureBaseString.Value, _consumer.Secret, null);

            oAuthParameters.SetSignature(signature);

            var header = new AuthorizationHeader(oAuthParameters, string.Empty);

            var req = (HttpWebRequest)WebRequest.Create("https://api.twitter.com/oauth/request_token");

            req.Headers.Add("Authorization", header.Value);

            var response = TInternet.Get(req);
            const HttpStatusCode expected = HttpStatusCode.OK;
            var actual = response.StatusCode;

            return new YesNoFixture(actual == expected, "Expected [" + expected +"]. Got [" +  actual+ "]", 2);
        }
Beispiel #3
0
 public AuthorizationHeader(OAuthParameters oAuthParameters, string realm)
 {
     _oAuthParameters = oAuthParameters;
     _realm = realm;
 }
Beispiel #4
0
 internal ParameterPart(Request request, OAuthParameters oAuthParameters)
 {
     _request         = request;
     _oAuthParameters = oAuthParameters;
 }
Beispiel #5
0
 internal ParameterPart(Request request, OAuthParameters oAuthParameters)
 {
     _request = request;
     _oAuthParameters = oAuthParameters;
 }
Beispiel #6
0
 public SignatureBaseString(Request request, OAuthParameters oAuthParameters)
 {
     _request = request;
     _oAuthParameters = oAuthParameters;
 }
 public Fixture Given_the_oauth_options()
 {
     return new OAuthParameterCollectingFixture().Tap(it =>
         it.Added += opts => _oauthParameters = opts
     );
 }