github.com/crewjam/saml@v0.4.14/samlsp/new_test.go (about)

     1  package samlsp
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  	"gotest.tools/assert"
     8  )
     9  
    10  func TestNewCanAcceptCookieName(t *testing.T) {
    11  
    12  	testCases := []struct {
    13  		testName   string
    14  		cookieName string
    15  		expected   string
    16  	}{
    17  		{"Works with alt name", "altCookie", "altCookie"},
    18  		{"Works with default", "", "token"},
    19  	}
    20  
    21  	for _, tc := range testCases {
    22  		t.Run(tc.testName, func(t *testing.T) {
    23  			opts := Options{
    24  				CookieName: tc.cookieName,
    25  			}
    26  			sp, err := New(opts)
    27  			require.Nil(t, err)
    28  			cookieProvider := sp.Session.(CookieSessionProvider)
    29  			assert.Equal(t, tc.expected, cookieProvider.Name)
    30  
    31  		})
    32  	}
    33  
    34  }