using Microsoft.VisualStudio.TestTools.UnitTesting;
using S22.Sasl.Mechanisms;
using System.Text;
namespace S22.Sasl.Test {
///
/// Contains unit tests for the SASL XOAUTH2 authentication mechanism.
///
[TestClass]
public class OAuth2Test {
///
/// Verifies the various parts of a sample authentication exchange
/// directly taken from Google's "XOAUTH2 Mechanism" document
/// ("Initial Client Response").
///
[TestMethod]
[TestCategory("OAuth2")]
public void VerifyAuthenticationExchange() {
SaslMechanism m = new SaslOAuth2("someuser@example.com",
"vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==");
string expectedResponse = "user=someuser@example.com\u0001" +
"auth=Bearer vF9dft4qmTc2Nvb3RlckBhdHRhdmlzdGEuY29tCg==\u0001\u0001";
string initialResponse = Encoding.ASCII.GetString(
m.GetResponse(new byte[0]));
Assert.AreEqual(expectedResponse, initialResponse);
}
}
}