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>
This commit is contained in:
Alex Ellis (VMware)
2018-08-13 10:20:13 +01:00
parent 87cfa097bc
commit 44ceb8da22
3 changed files with 150 additions and 71 deletions

View File

@ -0,0 +1,22 @@
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()
}
}