MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / init

Function init

pkg/oauth/server_test.go:89–126  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87var authCookie *http.Cookie
88
89func init() {
90 ctx := test.Context()
91
92 hashValidator := pbkdf2.Default()
93 hashValidator.Iterations = 10
94 ctx = auth.NewContextWithHashValidator(ctx, hashValidator)
95
96 password, err := auth.Hash(ctx, "pass")
97 if err != nil {
98 panic(err)
99 }
100 mockUser.Password = password
101
102 secret, err := auth.Hash(ctx, "secret")
103 if err != nil {
104 panic(err)
105 }
106 mockClient.Secret = secret
107
108 // Create session cookie
109 sc := securecookie.New(
110 []byte("12345678123456781234567812345678"),
111 []byte("12345678123456781234567812345678"),
112 )
113 authCookieContent := &auth.CookieShape{
114 UserID: "user",
115 SessionID: "session_id",
116 SessionSecret: "secret-1234",
117 }
118 encoded, _ := sc.Encode("_session", authCookieContent)
119 authCookie = &http.Cookie{
120 Name: "_session",
121 Value: encoded,
122 Path: "/",
123 Secure: true,
124 HttpOnly: true,
125 }
126}
127
128func TestOAuthFlow(t *testing.T) {
129 store := &mockStore{}

Callers

nothing calls this directly

Calls 6

ContextFunction · 0.92
DefaultFunction · 0.92
HashFunction · 0.92
NewMethod · 0.65
EncodeMethod · 0.65

Tested by

no test coverage detected