mirror of https://github.com/go-gitea/gitea
Merge c1a477d076
into b06aac40e6
This commit is contained in:
commit
2ba81713e7
|
@ -13,8 +13,6 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
//////////////////// Application
|
||||
|
||||
func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
|
||||
|
|
|
@ -584,6 +584,8 @@ var migrations = []Migration{
|
|||
NewMigration("Add missing field of commit status summary table", v1_23.AddCommitStatusSummary2),
|
||||
// v297 -> v298
|
||||
NewMigration("Add everyone_access_mode for repo_unit", v1_23.AddRepoUnitEveryoneAccessMode),
|
||||
// v298 -> v299
|
||||
NewMigration("Drop wrongly created table o_auth2_application", v1_23.DropWronglyCreatedTable),
|
||||
}
|
||||
|
||||
// GetCurrentDBVersion returns the current db version
|
||||
|
|
|
@ -7,11 +7,16 @@ import (
|
|||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
type oAuth2Application struct {
|
||||
ID int64
|
||||
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
|
||||
}
|
||||
|
||||
func (oAuth2Application) TableName() string {
|
||||
return "oauth2_application"
|
||||
}
|
||||
|
||||
// AddConfidentialColumnToOAuth2ApplicationTable: add ConfidentialClient column, setting existing rows to true
|
||||
func AddConfidentialClientColumnToOAuth2ApplicationTable(x *xorm.Engine) error {
|
||||
type OAuth2Application struct {
|
||||
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
|
||||
}
|
||||
|
||||
return x.Sync(new(OAuth2Application))
|
||||
return x.Sync(new(oAuth2Application))
|
||||
}
|
||||
|
|
|
@ -11,12 +11,16 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
|
||||
// premigration
|
||||
type OAuth2Application struct {
|
||||
ID int64
|
||||
}
|
||||
// premigration
|
||||
type OAuth2Application struct {
|
||||
ID int64
|
||||
}
|
||||
|
||||
func (OAuth2Application) TableName() string {
|
||||
return "oauth2_application"
|
||||
}
|
||||
|
||||
func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(OAuth2Application))
|
||||
defer deferable()
|
||||
|
@ -36,7 +40,7 @@ func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
|
|||
}
|
||||
|
||||
got := []ExpectedOAuth2Application{}
|
||||
if err := x.Table("o_auth2_application").Select("id, confidential_client").Find(&got); !assert.NoError(t, err) {
|
||||
if err := x.Table("oauth2_application").Select("id, confidential_client").Find(&got); !assert.NoError(t, err) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2024 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package v1_23 //nolint
|
||||
|
||||
import "xorm.io/xorm"
|
||||
|
||||
func DropWronglyCreatedTable(x *xorm.Engine) error {
|
||||
return x.DropTables("o_auth2_application")
|
||||
}
|
Loading…
Reference in New Issue