github.com/jxgolibs/go-oauth2-server@v1.0.1/util/password/password_test.go (about)

     1  package password_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/RichardKnop/go-oauth2-server/util/password"
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func TestVerifyPassword(t *testing.T) {
    11  	// Test valid passwords
    12  	assert.Nil(t, password.VerifyPassword(
    13  		"$2a$10$CUoGytf1pR7CC6Y043gt/.vFJUV4IRqvH5R6F0VfITP8s2TqrQ.4e",
    14  		"test_secret",
    15  	))
    16  
    17  	assert.Nil(t, password.VerifyPassword(
    18  		"$2a$10$4J4t9xuWhOKhfjN0bOKNReS9sL3BVSN9zxIr2.VaWWQfRBWh1dQIS",
    19  		"test_password",
    20  	))
    21  
    22  	// Test invalid password
    23  	assert.NotNil(t, password.VerifyPassword("bogus", "password"))
    24  }