github.com/nilium/gitlab-runner@v12.5.0+incompatible/helpers/url/scrub_secrets_test.go (about)

     1  package url_helpers
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestScrubSecrets(t *testing.T) {
    10  	examples := []struct {
    11  		input  string
    12  		output string
    13  	}{
    14  		{input: "Get http://localhost/?id=123", output: "Get http://localhost/?id=123"},
    15  		{input: "Get http://localhost/?id=123&X-Amz-Signature=abcd1234&private_token=abcd1234", output: "Get http://localhost/?id=123&X-Amz-Signature=[FILTERED]&private_token=[FILTERED]"},
    16  		{input: "Get http://localhost/?id=123&X-Amz-Credential=ABCDEF123456%2F20180920%2Fus-east-1%2Fs3%2Faws4_request", output: "Get http://localhost/?id=123&X-Amz-Credential=[FILTERED]"},
    17  		{input: "Get http://localhost/?private_token=abcd1234 test", output: "Get http://localhost/?private_token=[FILTERED] test"},
    18  	}
    19  
    20  	for _, example := range examples {
    21  		assert.Equal(t, example.output, ScrubSecrets(example.input))
    22  	}
    23  }