Skip to content

Commit

Permalink
Merge pull request #110 from edoardottt/add-tests
Browse files Browse the repository at this point in the history
Add tests for Revoked-SelfSigned certs (#109)
  • Loading branch information
Mzack9999 authored Nov 5, 2022
2 parents 3d5172c + e6910ae commit 3f499ae
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions internal/runner/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,58 @@ func Test_InputASN_processInputItem(t *testing.T) {
require.ElementsMatch(t, expected, got, "could not get correct taskInputs")
}

func Test_RevokedCert_processInputItem(t *testing.T) {
options := &clients.Options{
Ports: []string{"443"},
Revoked: true,
}
runner := &Runner{options: options}

inputs := make(chan taskInput)
domain := "revoked.badssl.com"
expected := []taskInput{
{
host: "revoked.badssl.com",
port: "443",
},
}
go func() {
runner.processInputItem(domain, inputs)
defer close(inputs)
}()
var got []taskInput
for task := range inputs {
got = append(got, task)
}
require.ElementsMatch(t, expected, got, "could not get correct taskInputs")
}

func Test_SelfSignedCert_processInputItem(t *testing.T) {
options := &clients.Options{
Ports: []string{"443"},
SelfSigned: true,
}
runner := &Runner{options: options}

inputs := make(chan taskInput)
domain := "self-signed.badssl.com"
expected := []taskInput{
{
host: "self-signed.badssl.com",
port: "443",
},
}
go func() {
runner.processInputItem(domain, inputs)
defer close(inputs)
}()
var got []taskInput
for task := range inputs {
got = append(got, task)
}
require.ElementsMatch(t, expected, got, "could not get correct taskInputs")
}

func getTaskInputFromFile(filename string, ports []string) ([]taskInput, error) {
fileContent, err := os.ReadFile(filename)
if err != nil {
Expand Down

0 comments on commit 3f499ae

Please sign in to comment.