mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 10:37:56 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			579 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package scram
 | |
| 
 | |
| import (
 | |
| 	"strings"
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/stretchr/testify/assert"
 | |
| )
 | |
| 
 | |
| // TestScram tests the Hash method. The hashed password string should have a SCRAM-SHA-256 prefix.
 | |
| func TestScram(t *testing.T) {
 | |
| 	tcs := map[string]struct {
 | |
| 		Password string
 | |
| 	}{
 | |
| 		"empty-password":  {Password: ""},
 | |
| 		"simple-password": {Password: "password"},
 | |
| 	}
 | |
| 
 | |
| 	for name, tc := range tcs {
 | |
| 		t.Run(name, func(t *testing.T) {
 | |
| 			got, err := Hash(tc.Password)
 | |
| 			assert.NoError(t, err)
 | |
| 			assert.True(t, strings.HasPrefix(got, "SCRAM-SHA-256$4096:"))
 | |
| 			assert.Len(t, got, 133)
 | |
| 		})
 | |
| 	}
 | |
| }
 | 
