(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func TestBcrypt(t *testing.T) { |
| 157 | // all use the `test` password |
| 158 | |
| 159 | examples := []string{ |
| 160 | "$2y$04$mIJxfrCaEI3GukZe11CiXublhEFanu5.ododkll1WphfSp6pn4zIu", |
| 161 | "$2y$10$srNl09aPtc2qr.0Vl.NtjekJRt/NxRxYQm3qd3OvfcKsJgVnr6.Ve", |
| 162 | } |
| 163 | |
| 164 | for _, example := range examples { |
| 165 | assert.NoError(t, CompareHashAndPassword(context.Background(), example, "test")) |
| 166 | } |
| 167 | |
| 168 | for _, example := range examples { |
| 169 | assert.Error(t, CompareHashAndPassword(context.Background(), example, "test1")) |
| 170 | } |
| 171 | |
| 172 | negativeExamples := []string{ |
| 173 | "not-a-hash", |
| 174 | } |
| 175 | for _, example := range negativeExamples { |
| 176 | assert.Error(t, CompareHashAndPassword(context.Background(), example, "test")) |
| 177 | } |
| 178 | } |
nothing calls this directly
no test coverage detected