Some checks failed
Build and Release / Create Release (push) Successful in 0s
Trigger Vault Plugin Rebuild / Trigger Vault Rebuild (push) Successful in 0s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 2m48s
Build and Release / Lint (push) Failing after 5m2s
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, darwin, linux-latest) (push) Has been skipped
Build and Release / Build Binaries (arm64, linux, linux-latest) (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 5m37s
Go's semantic import versioning requires v2+ modules to include the major version in the module path. This enables using proper version tags (v3.x.x) instead of pseudo-versions. Updated module path: code.gitcaddy.com/server/v3
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package integration
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
"time"
|
|
|
|
auth_model "code.gitcaddy.com/server/v3/models/auth"
|
|
"code.gitcaddy.com/server/v3/models/unittest"
|
|
user_model "code.gitcaddy.com/server/v3/models/user"
|
|
api "code.gitcaddy.com/server/v3/modules/structs"
|
|
"code.gitcaddy.com/server/v3/services/convert"
|
|
"code.gitcaddy.com/server/v3/tests"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestAPITeamUser(t *testing.T) {
|
|
defer tests.PrepareTestEnv(t)()
|
|
user2Session := loginUser(t, "user2")
|
|
user2Token := getTokenForLoggedInUser(t, user2Session, auth_model.AccessTokenScopeWriteOrganization)
|
|
|
|
t.Run("User2ReadUser1", func(t *testing.T) {
|
|
req := NewRequest(t, "GET", "/api/v1/teams/1/members/user1").AddTokenAuth(user2Token)
|
|
MakeRequest(t, req, http.StatusNotFound)
|
|
})
|
|
|
|
t.Run("User2ReadSelf", func(t *testing.T) {
|
|
// read self user
|
|
req := NewRequest(t, "GET", "/api/v1/teams/1/members/user2").AddTokenAuth(user2Token)
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
|
var user2 *api.User
|
|
DecodeJSON(t, resp, &user2)
|
|
user2.Created = user2.Created.In(time.Local)
|
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{Name: "user2"})
|
|
|
|
expectedUser := convert.ToUser(t.Context(), user, user)
|
|
|
|
// test time via unix timestamp
|
|
assert.Equal(t, expectedUser.LastLogin.Unix(), user2.LastLogin.Unix())
|
|
assert.Equal(t, expectedUser.Created.Unix(), user2.Created.Unix())
|
|
expectedUser.LastLogin = user2.LastLogin
|
|
expectedUser.Created = user2.Created
|
|
|
|
assert.Equal(t, expectedUser, user2)
|
|
})
|
|
}
|