public void ValidateSignature_PassEmptyString_ReturnFalse() { // Arrange string validToken = ""; JWTokenManager jwtManager = new JWTokenManager(); bool expected = false; // Act bool actual = jwtManager.ValidateSignature(validToken); // Assert Assert.Equal(expected, actual); }
public AuthorizationManager(string token) { JWTokenManager jwtManager = new JWTokenManager(); if (token == null) { throw new ArgumentNullException("token"); } else if (!jwtManager.ValidateSignature(token)) { throw new ArgumentException("token", "Not a valid JSON Web Token."); } this.context = new SecurityContext(token); }
public void ValidateSignature_PassTokenWithNoSignature_ReturnFalse() { // Arrange string validToken = "eyJhbGciOiJTSEEyNTYiLCJ0eXAiOiJKV1QifQ" + ".eyJ1c2VyIjoidGVzdEBlbWFpbC5jb20iLCJjbGFpbSI6IltQb3N0LCBEZWxldGUsIEVkaXRdIn0"; JWTokenManager jwtManager = new JWTokenManager(); bool expected = false; // Act bool actual = jwtManager.ValidateSignature(validToken); // Assert Assert.Equal(expected, actual); }
public void ValidateSignature_PassTokenWithValidSignature_ReturnTrue() { // Arrange string validToken = "eyJhbGciOiJTSEEyNTYiLCJ0eXAiOiJKV1QifQ" + ".eyJ1c2VyIjoidGVzdEBlbWFpbC5jb20iLCJjbGFpbSI6IltQb3N0LCBEZWxldGUsIEVkaXRdIn0" + ".a_ZtyrD4iNplCbpCXUxPySaNWySp3enUEI57ib5Vw4U"; JWTokenManager jwtManager = new JWTokenManager(); bool expected = true; // Act bool actual = jwtManager.ValidateSignature(validToken); // Assert Assert.Equal(expected, actual); }