snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
13
test/fake/device.go
Normal file
13
test/fake/device.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// Device creates a context with a fake device.
|
||||
func Device(device *model.Device) context.Context {
|
||||
return auth.WithDevice(context.Background(), device)
|
||||
}
|
||||
22
test/fake/user.go
Normal file
22
test/fake/user.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package fake
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// User create a context with a fake user.
|
||||
func User(id int) context.Context {
|
||||
return UserWithPerm(id, true)
|
||||
}
|
||||
|
||||
// UserWithPerm create a context with a fake user.
|
||||
func UserWithPerm(id int, admin bool) context.Context {
|
||||
return auth.WithUser(context.Background(), &model.User{
|
||||
ID: id,
|
||||
Name: "fake",
|
||||
Admin: admin,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user