Alex Ellis (VMware) 44ceb8da22 Add haveibeenpwned sample function
Idea from Matthew Holt, using the haveibeenpwned API to query
whether a password has been found in a data-breach.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
2018-08-13 10:20:13 +01:00

23 lines
381 B
Go

package function
import (
"encoding/json"
"testing"
)
func Test_Handle(t *testing.T) {
res := Handle([]byte("test1234"))
result := result{}
err := json.Unmarshal([]byte(res), &result)
if err != nil {
t.Errorf("unable to unmarshal response, error: %s", err)
t.Fail()
}
if result.Found == 0 {
t.Errorf("expected test1234 to be found several times")
t.Fail()
}
}