code.gitea.io/gitea@v1.19.3/modules/auth/password/hash/dummy_test.go (about)

     1  // Copyright 2023 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package hash
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/stretchr/testify/assert"
    10  )
    11  
    12  func TestDummyHasher(t *testing.T) {
    13  	dummy := &PasswordHashAlgorithm{
    14  		PasswordSaltHasher: NewDummyHasher(""),
    15  		Specification:      "dummy",
    16  	}
    17  
    18  	password, salt := "password", "ZogKvWdyEx"
    19  
    20  	hash, err := dummy.Hash(password, salt)
    21  	assert.Nil(t, err)
    22  	assert.Equal(t, hash, salt+":"+password)
    23  
    24  	assert.True(t, dummy.VerifyPassword(password, hash, salt))
    25  }