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); }