Skip to content

Commit

Permalink
Use different userId for unnauthorized tests to avoid concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavia Pezoti committed Jul 5, 2021
1 parent 7940818 commit 148d50a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/histories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ func TestHistoriesHandler(t *testing.T) {
})

g.It("It should return 401 if the user is not authorized into the topics", func() {
userID := fmt.Sprintf("test:%s", uuid.NewV4().String())
testID := strings.Replace(uuid.NewV4().String(), "-", "", -1)
path := fmt.Sprintf("/history/chat/test_?userid=test:test&topics=%s", testID)
testID2 := strings.Replace(uuid.NewV4().String(), "-", "", -1)
path := fmt.Sprintf("/v2/histories/chat/test?userid=%s&topics=%s,%s", userID, testID, testID2)
status, _ := Get(a, path, t)
g.Assert(status).Equal(http.StatusUnauthorized)
})
Expand Down
3 changes: 2 additions & 1 deletion app/histories_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ func TestHistoriesV2Handler(t *testing.T) {
g.Describe("HistoriesV2 Handler", func() {

g.It("It should return 401 if the user is not authorized into the topics", func() {
userID := fmt.Sprintf("test:%s", uuid.NewV4().String())
testID := strings.Replace(uuid.NewV4().String(), "-", "", -1)
testID2 := strings.Replace(uuid.NewV4().String(), "-", "", -1)
path := fmt.Sprintf("/v2/histories/chat/test?userid=test:test&topics=%s,%s", testID, testID2)
path := fmt.Sprintf("/v2/histories/chat/test?userid=%s&topics=%s,%s", userID, testID, testID2)
status, _ := Get(a, path, t)
g.Assert(status).Equal(http.StatusUnauthorized)
})
Expand Down
3 changes: 2 additions & 1 deletion app/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func TestHistoryHandler(t *testing.T) {

g.Describe("History Handler", func() {
g.It("It should return 401 if the user is not authorized into the topic", func() {
userID := fmt.Sprintf("test:%s", uuid.NewV4().String())
testID := strings.Replace(uuid.NewV4().String(), "-", "", -1)
path := fmt.Sprintf("/history/chat/test_%s?userid=test:test", testID)
path := fmt.Sprintf("/history/chat/test_%s?userid=%s", testID, userID)
status, _ := Get(a, path, t)
g.Assert(status).Equal(http.StatusUnauthorized)
})
Expand Down
3 changes: 2 additions & 1 deletion app/history_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ func TestHistoryV2Handler(t *testing.T) {

g.Describe("HistoryV2 Handler", func() {
g.It("It should return 401 if the user is not authorized into the topic", func() {
userID := fmt.Sprintf("test:%s", uuid.NewV4().String())
testID := strings.Replace(uuid.NewV4().String(), "-", "", -1)
path := fmt.Sprintf("/v2/history/chat/test_%s?userid=test:test", testID)
path := fmt.Sprintf("/v2/history/chat/test_%s?userid=%s", testID, userID)
status, _ := Get(a, path, t)
g.Assert(status).Equal(http.StatusUnauthorized)
})
Expand Down

0 comments on commit 148d50a

Please sign in to comment.