forked from ory/fosite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_write_test.go
36 lines (29 loc) · 969 Bytes
/
access_write_test.go
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
31
32
33
34
35
36
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package fosite_test
import (
"context"
"net/http"
"testing"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
. "github.com/ory/fosite"
. "github.com/ory/fosite/internal"
)
func TestWriteAccessResponse(t *testing.T) {
f := &Fosite{Config: new(Config)}
header := http.Header{}
ctrl := gomock.NewController(t)
rw := NewMockResponseWriter(ctrl)
ar := NewMockAccessRequester(ctrl)
resp := NewMockAccessResponder(ctrl)
defer ctrl.Finish()
rw.EXPECT().Header().AnyTimes().Return(header)
rw.EXPECT().WriteHeader(http.StatusOK)
rw.EXPECT().Write(gomock.Any())
resp.EXPECT().ToMap().Return(map[string]interface{}{})
f.WriteAccessResponse(context.Background(), rw, ar, resp)
assert.Equal(t, "application/json;charset=UTF-8", header.Get("Content-Type"))
assert.Equal(t, "no-store", header.Get("Cache-Control"))
assert.Equal(t, "no-cache", header.Get("Pragma"))
}