public void OAuth2CryptographicCodeGenerator_CreatePkceCodeChallenge_Plain_ReturnsVerifierUnchanged() { var generator = new OAuth2CryptographicCodeGenerator(); var verifier = generator.CreatePkceCodeVerifier(); var challenge = generator.CreatePkceCodeChallenge(OAuth2PkceChallengeMethod.Plain, verifier); Assert.Equal(verifier, challenge); }
public void OAuth2CryptographicCodeGenerator_CreatePkceCodeChallenge_Sha256_ReturnsBase64UrlEncodedSha256HashOfAsciiVerifier() { var generator = new OAuth2CryptographicCodeGenerator(); var verifier = generator.CreatePkceCodeVerifier(); byte[] verifierAsciiBytes = Encoding.ASCII.GetBytes(verifier); byte[] hashedBytes; using (var sha256 = SHA256.Create()) { hashedBytes = sha256.ComputeHash(verifierAsciiBytes); } var expectedChallenge = Base64UrlConvert.Encode(hashedBytes, false); var actualChallenge = generator.CreatePkceCodeChallenge(OAuth2PkceChallengeMethod.Sha256, verifier); Assert.Equal(expectedChallenge, actualChallenge); }