| 87 | var authCookie *http.Cookie |
| 88 | |
| 89 | func 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 | |
| 128 | func TestOAuthFlow(t *testing.T) { |
| 129 | store := &mockStore{} |