Browse Source

Add integration test for logging out (#2892)

Ethan Koenig 1 year ago
parent
commit
5abd1d2a68
1 changed files with 26 additions and 0 deletions
  1. 26 0
      integrations/signout_test.go

+ 26 - 0
integrations/signout_test.go

@@ -0,0 +1,26 @@
1
+// Copyright 2017 The Gitea Authors. All rights reserved.
2
+// Use of this source code is governed by a MIT-style
3
+// license that can be found in the LICENSE file.
4
+
5
+package integrations
6
+
7
+import (
8
+	"net/http"
9
+	"testing"
10
+)
11
+
12
+func TestSignOut(t *testing.T) {
13
+	prepareTestEnv(t)
14
+
15
+	session := loginUser(t, "user2")
16
+
17
+	req := NewRequest(t, "GET", "/user/logout")
18
+	session.MakeRequest(t, req, http.StatusFound)
19
+
20
+	// try to view a private repo, should fail
21
+	req = NewRequest(t, "GET", "/user2/repo2/")
22
+	session.MakeRequest(t, req, http.StatusNotFound)
23
+
24
+	// invalidate cached cookies for user2, for subsequent tests
25
+	delete(loginSessionCache, "user2")
26
+}