mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-15 13:52:33 +00:00
added test for federated user
This commit is contained in:
parent
67f3f66be4
commit
a702da69cc
5 changed files with 34 additions and 3 deletions
|
@ -15,8 +15,7 @@ import (
|
|||
// FederationHost data type
|
||||
// swagger:model
|
||||
type FederationHost struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
// TODO: implement a toLower here & add a toLowerValidation
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
HostFqdn string `xorm:"host_fqdn UNIQUE INDEX VARCHAR(255) NOT NULL"`
|
||||
NodeInfo NodeInfo `xorm:"extends NOT NULL"`
|
||||
LatestActivity time.Time `xorm:"NOT NULL"`
|
||||
|
|
29
models/user/federated_user_test.go
Normal file
29
models/user/federated_user_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/modules/validation"
|
||||
)
|
||||
|
||||
func Test_FederatedUserValidation(t *testing.T) {
|
||||
sut := FederatedUser{
|
||||
UserID: 12,
|
||||
ExternalID: "12",
|
||||
FederationHostID: 1,
|
||||
}
|
||||
if res, err := validation.IsValid(sut); !res {
|
||||
t.Errorf("sut should be valid but was %q", err)
|
||||
}
|
||||
|
||||
sut = FederatedUser{
|
||||
ExternalID: "12",
|
||||
FederationHostID: 1,
|
||||
}
|
||||
if res, _ := validation.IsValid(sut); res {
|
||||
t.Errorf("sut should be invalid")
|
||||
}
|
||||
}
|
2
models/user/user_repository.go
Normal file
2
models/user/user_repository.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
2
models/user/user_service.go
Normal file
2
models/user/user_service.go
Normal file
|
@ -0,0 +1,2 @@
|
|||
// Copyright 2024 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
|
@ -245,7 +245,6 @@ func createFederationInfo(ctx *context.APIContext, actorID forgefed.ActorID) (fo
|
|||
return result, nil
|
||||
}
|
||||
|
||||
// ToDo: Maybe use externalLoginUser
|
||||
func createUserFromAP(ctx *context.APIContext, personID forgefed.PersonID) (*user_model.User, error) {
|
||||
// ToDo: Do we get a publicKeyId from server, repo or owner or repo?
|
||||
actionsUser := user_model.NewActionsUser()
|
||||
|
|
Loading…
Reference in a new issue