You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boundary/internal/servers/controller/handlers/outgoing_interceptor_test.go

25 lines
786 B

package handlers
import (
"context"
"net/http"
"net/http/httptest"
"testing"
pb "github.com/hashicorp/boundary/internal/gen/controller/api/resources/authtokens"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/stretchr/testify/assert"
)
func TestOutgoingSplitCookie(t *testing.T) {
rec := httptest.NewRecorder()
OutgoingInterceptor(context.Background(), rec, &pbs.AuthenticateResponse{
TokenType: "cookie",
Item: &pb.AuthToken{Token: "t_abc_1234567890"},
})
assert.ElementsMatch(t, rec.Result().Cookies(), []*http.Cookie{
{Name: HttpOnlyCookieName, Value: "34567890", HttpOnly: true, Raw: "wt-http-token-cookie=34567890; HttpOnly"},
{Name: JsVisibleCookieName, Value: "t_abc_12", Raw: "wt-js-token-cookie=t_abc_12"},
})
}