Implement GetOrCreateApplicationAuthentication

Implements the endpoint for creating an application authorization token.
This commit is contained in:
Haacked
2013-10-09 16:28:59 -07:00
parent 9d71d406fa
commit 33ad79c0fe
19 changed files with 653 additions and 4 deletions

View File

@@ -34,3 +34,42 @@ namespace Octokit
#endif
}
}
/*
[Fact]
public void CreatesGitHubErrorFromJsonResponse()
{
var exception = new ApiUnauthorizedWebException("{\"message\":\"Bad credentials.\"}");
exception.ApiUnauthorizedError.Message.ShouldEqual("Bad credentials.");
exception.ApiUnauthorizedError.Errors.ShouldBeNull();
}
[Theory]
[InlineData("")]
[InlineData(null)]
[InlineData("{{{{{")]
public void CreatesGitHubErrorIfResponseMessageIsNotValidJson(string responseContent)
{
var exception = new ApiUnauthorizedWebException(responseContent);
exception.ApiUnauthorizedError.Message.ShouldEqual(responseContent);
Assert.False(exception.RequiresSecondFactor);
}
[Fact]
public void CanPopulateObjectFromSerializedData()
{
var exception = new ApiUnauthorizedWebException("{message:\"Bad credentials.\"}");
using (var stream = new MemoryStream())
{
var formatter = new BinaryFormatter();
formatter.Serialize(stream, exception);
stream.Position = 0;
var deserialized = (ApiUnauthorizedWebException)formatter.Deserialize(stream);
deserialized.ApiUnauthorizedError.Message.ShouldEqual("Bad credentials.");
exception.ApiUnauthorizedError.Errors.ShouldBeNull();
}
}
*/