@@ -611,6 +611,36 @@ func TestAuthOnlyEndpointUnauthorizedOnEmailValidationFailure(t *testing.T) {
611611 assert.Equal(t, "unauthorized request\n", string(bodyBytes))
612612}
613613
614+func TestAuthOnlyEndpointSetXAuthRequestHeaders(t *testing.T) {
615+ var pc_test ProcessCookieTest
616+
617+ pc_test.opts = NewOptions()
618+ pc_test.opts.SetXAuthRequest = true
619+ pc_test.opts.Validate()
620+
621+ pc_test.proxy = NewOAuthProxy(pc_test.opts, func(email string) bool {
622+ return pc_test.validate_user
623+ })
624+ pc_test.proxy.provider = &TestProvider{
625+ ValidToken: true,
626+ }
627+
628+ pc_test.validate_user = true
629+
630+ pc_test.rw = httptest.NewRecorder()
631+ pc_test.req, _ = http.NewRequest("GET",
632+ pc_test.opts.ProxyPrefix+"/auth", nil)
633+
634+ startSession := &providers.SessionState{
635+ User: "oauth_user", Email: "oauth_user@example.com", AccessToken: "oauth_token"}
636+ pc_test.SaveSession(startSession, time.Now())
637+
638+ pc_test.proxy.ServeHTTP(pc_test.rw, pc_test.req)
639+ assert.Equal(t, http.StatusAccepted, pc_test.rw.Code)
640+ assert.Equal(t, "oauth_user", pc_test.rw.HeaderMap["X-Auth-Request-User"][0])
641+ assert.Equal(t, "oauth_user@example.com", pc_test.rw.HeaderMap["X-Auth-Request-Email"][0])
642+}
643+
614644type SignatureAuthenticator struct {
615645 auth hmacauth.HmacAuth
616646}