aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/httputil/headers/authorization_test.go
blob: 4e93aac1cd4ddf9ec0e876521af3387a0be6e522 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package headers_test

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/ydb-platform/ydb/library/go/httputil/headers"
)

func TestAuthorizationTokenType(t *testing.T) {
	testCases := []struct {
		name     string
		token    string
		expected headers.TokenType
	}{
		{"bearer", "bearer ololo.trololo", headers.TokenTypeBearer},
		{"Bearer", "Bearer ololo.trololo", headers.TokenTypeBearer},
		{"BEARER", "BEARER ololo.trololo", headers.TokenTypeBearer},
		{"mac", "mac ololo.trololo", headers.TokenTypeMAC},
		{"Mac", "Mac ololo.trololo", headers.TokenTypeMAC},
		{"MAC", "MAC ololo.trololo", headers.TokenTypeMAC},
		{"unknown", "shimba ololo.trololo", headers.TokenType("unknown")},
	}

	for _, tc := range testCases {
		t.Run(tc.name, func(t *testing.T) {
			assert.Equal(t, tc.expected, headers.AuthorizationTokenType(tc.token))
		})
	}
}