mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-06-05 17:08:50 +00:00
Merge branch 'origin/main' into 'next-release/main'
This commit is contained in:
commit
62f1535d3e
4 changed files with 46 additions and 4 deletions
|
@ -44,10 +44,10 @@ type User struct {
|
||||||
Login string `json:"login" xorm:"UNIQUE 'login'"`
|
Login string `json:"login" xorm:"UNIQUE 'login'"`
|
||||||
|
|
||||||
// AccessToken is the oauth2 access token.
|
// AccessToken is the oauth2 access token.
|
||||||
AccessToken string `json:"-" xorm:"TEXT 'token'"`
|
AccessToken string `json:"-" xorm:"TEXT 'access_token'"`
|
||||||
|
|
||||||
// RefreshToken is the oauth2 refresh token.
|
// RefreshToken is the oauth2 refresh token.
|
||||||
RefreshToken string `json:"-" xorm:"TEXT 'secret'"`
|
RefreshToken string `json:"-" xorm:"TEXT 'refresh_token'"`
|
||||||
|
|
||||||
// Expiry is the AccessToken expiration timestamp (unix seconds).
|
// Expiry is the AccessToken expiration timestamp (unix seconds).
|
||||||
Expiry int64 `json:"-" xorm:"expiry"`
|
Expiry int64 `json:"-" xorm:"expiry"`
|
||||||
|
|
|
@ -35,7 +35,7 @@ var (
|
||||||
Data: []byte("{}"),
|
Data: []byte("{}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitForProcess = func() { time.Sleep(processTimeInterval + 10*time.Millisecond) }
|
waitForProcess = func() { time.Sleep(processTimeInterval + 50*time.Millisecond) }
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFifo(t *testing.T) {
|
func TestFifo(t *testing.T) {
|
||||||
|
@ -83,10 +83,10 @@ func TestFifoExpire(t *testing.T) {
|
||||||
assert.Len(t, info.Pending, 1, "expect task in pending queue")
|
assert.Len(t, info.Pending, 1, "expect task in pending queue")
|
||||||
|
|
||||||
got, err := q.Poll(ctx, 1, filterFnTrue)
|
got, err := q.Poll(ctx, 1, filterFnTrue)
|
||||||
waitForProcess()
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, dummyTask, got)
|
assert.Equal(t, dummyTask, got)
|
||||||
|
|
||||||
|
waitForProcess()
|
||||||
info = q.Info(ctx)
|
info = q.Info(ctx)
|
||||||
assert.Len(t, info.Pending, 1, "expect task re-added to pending queue")
|
assert.Len(t, info.Pending, 1, "expect task re-added to pending queue")
|
||||||
}
|
}
|
||||||
|
|
41
server/store/datastore/migration/021_rename_token_fields.go
Normal file
41
server/store/datastore/migration/021_rename_token_fields.go
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright 2024 Woodpecker Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package migration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"src.techknowlogick.com/xormigrate"
|
||||||
|
"xorm.io/xorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
var renameTokenFields = xormigrate.Migration{
|
||||||
|
ID: "rename-token-fields",
|
||||||
|
MigrateSession: func(sess *xorm.Session) (err error) {
|
||||||
|
type users struct {
|
||||||
|
AccessToken string `xorm:"TEXT 'token'"`
|
||||||
|
RefreshToken string `xorm:"TEXT 'secret'"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure columns to rename exist
|
||||||
|
if err := sess.Sync(new(users)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := renameColumn(sess, "users", "token", "access_token"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return renameColumn(sess, "users", "secret", "refresh_token")
|
||||||
|
},
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ var migrationTasks = []*xormigrate.Migration{
|
||||||
&correctPotentialCorruptOrgsUsersRelation,
|
&correctPotentialCorruptOrgsUsersRelation,
|
||||||
&gatedToRequireApproval,
|
&gatedToRequireApproval,
|
||||||
&removeRepoNetrcOnlyTrusted,
|
&removeRepoNetrcOnlyTrusted,
|
||||||
|
&renameTokenFields,
|
||||||
}
|
}
|
||||||
|
|
||||||
var allBeans = []any{
|
var allBeans = []any{
|
||||||
|
|
Loading…
Reference in a new issue