2017-03-06 14:13:17 +00:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-27 18:20:29 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-03-06 14:13:17 +00:00
|
|
|
|
2022-09-02 19:18:23 +00:00
|
|
|
package integration
|
2017-03-06 14:13:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
|
2023-07-23 19:52:33 +00:00
|
|
|
auth_model "code.gitea.io/gitea/models/auth"
|
2017-04-25 07:24:51 +00:00
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2019-05-11 10:21:34 +00:00
|
|
|
"code.gitea.io/gitea/modules/structs"
|
2022-09-02 19:18:23 +00:00
|
|
|
"code.gitea.io/gitea/tests"
|
2017-03-06 14:13:17 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2017-04-25 07:24:51 +00:00
|
|
|
func TestVersion(t *testing.T) {
|
2022-09-02 19:18:23 +00:00
|
|
|
defer tests.PrepareTestEnv(t)()
|
2017-03-06 14:13:17 +00:00
|
|
|
|
2017-10-12 11:40:42 +00:00
|
|
|
setting.AppVer = "test-version-1"
|
2017-06-10 00:41:36 +00:00
|
|
|
req := NewRequest(t, "GET", "/api/v1/version")
|
2017-07-07 19:36:47 +00:00
|
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
2017-03-06 14:13:17 +00:00
|
|
|
|
2019-05-11 10:21:34 +00:00
|
|
|
var version structs.ServerVersion
|
2017-06-18 09:06:17 +00:00
|
|
|
DecodeJSON(t, resp, &version)
|
2019-07-23 18:50:39 +00:00
|
|
|
assert.Equal(t, setting.AppVer, version.Version)
|
2023-07-23 19:52:33 +00:00
|
|
|
|
|
|
|
// Verify https://codeberg.org/forgejo/forgejo/pulls/1098 is fixed
|
|
|
|
{
|
|
|
|
token := getUserToken(t, "user2", auth_model.AccessTokenScopeReadActivityPub)
|
|
|
|
req := NewRequestf(t, "GET", "/api/v1/version?token=%s", token)
|
|
|
|
resp := MakeRequest(t, req, http.StatusOK)
|
|
|
|
|
|
|
|
var version structs.ServerVersion
|
|
|
|
DecodeJSON(t, resp, &version)
|
|
|
|
assert.Equal(t, setting.AppVer, version.Version)
|
|
|
|
}
|
2017-03-06 14:13:17 +00:00
|
|
|
}
|