MCPcopy Create free account
hub / github.com/gogs/gogs / TestEncodePassword

Function TestEncodePassword

internal/userutil/userutil_test.go:105–143  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

103}
104
105func TestEncodePassword(t *testing.T) {
106 want := EncodePassword("123456", "rands")
107 tests := []struct {
108 name string
109 password string
110 rands string
111 wantEqual bool
112 }{
113 {
114 name: "correct",
115 password: "123456",
116 rands: "rands",
117 wantEqual: true,
118 },
119
120 {
121 name: "wrong password",
122 password: "111333",
123 rands: "rands",
124 wantEqual: false,
125 },
126 {
127 name: "wrong salt",
128 password: "111333",
129 rands: "salt",
130 wantEqual: false,
131 },
132 }
133 for _, test := range tests {
134 t.Run(test.name, func(t *testing.T) {
135 got := EncodePassword(test.password, test.rands)
136 if test.wantEqual {
137 assert.Equal(t, want, got)
138 } else {
139 assert.NotEqual(t, want, got)
140 }
141 })
142 }
143}
144
145func TestValidatePassword(t *testing.T) {
146 want := EncodePassword("123456", "rands")

Callers

nothing calls this directly

Calls 1

EncodePasswordFunction · 0.85

Tested by

no test coverage detected