mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
chore: do not clobber ~/.ssh/authorized_keys in certain tests (#10163)
The running of `make test` without any additional options will result in the tampering with of ~/.ssh/authorized_keys. This ensures that the tests use a temporary directory by setting SSH.RootPath consistent with other tests in this codebase. Resolves forgejo/forgejo#10164 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10163 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Kevin Schoon <me@kevinschoon.com> Co-committed-by: Kevin Schoon <me@kevinschoon.com>
This commit is contained in:
parent
255ed593d3
commit
363a712aa2
2 changed files with 6 additions and 0 deletions
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"forgejo.org/models/db"
|
"forgejo.org/models/db"
|
||||||
"forgejo.org/models/unittest"
|
"forgejo.org/models/unittest"
|
||||||
user_model "forgejo.org/models/user"
|
user_model "forgejo.org/models/user"
|
||||||
|
"forgejo.org/modules/setting"
|
||||||
|
"forgejo.org/modules/test"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
@ -18,6 +20,7 @@ import (
|
||||||
|
|
||||||
func TestAddLdapSSHPublicKeys(t *testing.T) {
|
func TestAddLdapSSHPublicKeys(t *testing.T) {
|
||||||
require.NoError(t, unittest.PrepareTestDatabase())
|
require.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
defer test.MockVariableValue(&setting.SSH.RootPath, t.TempDir())()
|
||||||
|
|
||||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||||
s := &auth.Source{ID: 1}
|
s := &auth.Source{ID: 1}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"forgejo.org/models/unittest"
|
"forgejo.org/models/unittest"
|
||||||
|
"forgejo.org/modules/setting"
|
||||||
|
"forgejo.org/modules/test"
|
||||||
driver_options "forgejo.org/services/f3/driver/options"
|
driver_options "forgejo.org/services/f3/driver/options"
|
||||||
|
|
||||||
_ "forgejo.org/models"
|
_ "forgejo.org/models"
|
||||||
|
|
@ -22,6 +24,7 @@ import (
|
||||||
|
|
||||||
func TestF3(t *testing.T) {
|
func TestF3(t *testing.T) {
|
||||||
require.NoError(t, unittest.PrepareTestDatabase())
|
require.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
defer test.MockVariableValue(&setting.SSH.RootPath, t.TempDir())()
|
||||||
tests_f3.ForgeCompliance(t, driver_options.Name)
|
tests_f3.ForgeCompliance(t, driver_options.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue