8 "github.com/stretchr/testify/assert"
9 "golang.org/x/crypto/bcrypt"
12func TestSHA(t *testing.T) {
13 file := bytes.NewBuffer([]byte("testuser:{SHA}PaVBVZkYqAjCQCu6UBL2xgsnZhw=\n"))
14 h, err := NewHtpasswd(file)
15 assert.Equal(t, err, nil)
17 valid := h.Validate("testuser", "asdf")
18 assert.Equal(t, valid, true)
21func TestBcrypt(t *testing.T) {
22 hash1, err := bcrypt.GenerateFromPassword([]byte("password"), 1)
23 assert.Equal(t, err, nil)
24 hash2, err := bcrypt.GenerateFromPassword([]byte("top-secret"), 2)
25 assert.Equal(t, err, nil)
27 contents := fmt.Sprintf("testuser1:%s\ntestuser2:%s\n", hash1, hash2)
28 file := bytes.NewBuffer([]byte(contents))
30 h, err := NewHtpasswd(file)
31 assert.Equal(t, err, nil)
33 valid := h.Validate("testuser1", "password")
34 assert.Equal(t, valid, true)
36 valid = h.Validate("testuser2", "top-secret")
37 assert.Equal(t, valid, true)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list