github.com/prebid/prebid-server/v2@v2.18.0/privacy/gdpr/validate_test.go (about)

     1  package gdpr
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestValidateConsent(t *testing.T) {
    10  	testCases := []struct {
    11  		description string
    12  		consent     string
    13  		expected    bool
    14  	}{
    15  		{
    16  			description: "Invalid",
    17  			consent:     "<any invalid>",
    18  			expected:    false,
    19  		},
    20  		{
    21  			description: "TCF2 Valid",
    22  			consent:     "COzTVhaOzTVhaGvAAAENAiCIAP_AAH_AAAAAAEEUACCKAAA",
    23  			expected:    true,
    24  		},
    25  	}
    26  
    27  	for _, test := range testCases {
    28  		result := ValidateConsent(test.consent)
    29  		assert.Equal(t, test.expected, result, test.description)
    30  	}
    31  }