mirror of
https://github.com/openfaas/faas.git
synced 2025-06-22 06:43:23 +00:00
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:
22
sample-functions/haveibeenpwned/handler_test.go
Normal file
22
sample-functions/haveibeenpwned/handler_test.go
Normal 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()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user