...

Source file src/github.com/letsencrypt/boulder/va/utf8filter_test.go

Documentation: github.com/letsencrypt/boulder/va

     1  package va
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/letsencrypt/boulder/probs"
     7  	"github.com/letsencrypt/boulder/test"
     8  )
     9  
    10  func TestReplaceInvalidUTF8(t *testing.T) {
    11  	input := "f\xffoo"
    12  	expected := "f\ufffdoo"
    13  	result := replaceInvalidUTF8([]byte(input))
    14  	if result != expected {
    15  		t.Errorf("replaceInvalidUTF8(%q): got %q, expected %q", input, result, expected)
    16  	}
    17  }
    18  
    19  func TestFilterProblemDetails(t *testing.T) {
    20  	test.Assert(t, filterProblemDetails(nil) == nil, "nil should filter to nil")
    21  	result := filterProblemDetails(&probs.ProblemDetails{
    22  		Type:       probs.ProblemType([]byte{0xff, 0xfe, 0xfd}),
    23  		Detail:     "seems okay so far whoah no \xFF\xFE\xFD",
    24  		HTTPStatus: 999,
    25  	})
    26  
    27  	expected := &probs.ProblemDetails{
    28  		Type:       "���",
    29  		Detail:     "seems okay so far whoah no ���",
    30  		HTTPStatus: 999,
    31  	}
    32  	test.AssertDeepEquals(t, result, expected)
    33  }
    34  

View as plain text