Compare commits
2 commits
33f140595c
...
bdc625b57e
| Author | SHA1 | Date | |
|---|---|---|---|
| bdc625b57e | |||
| 0e2d302804 |
8 changed files with 130 additions and 6 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.task/
|
||||||
|
|
@ -19,6 +19,8 @@ tasks:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
desc: Build server binary
|
desc: Build server binary
|
||||||
|
sources:
|
||||||
|
- '**/*.go'
|
||||||
generates:
|
generates:
|
||||||
- build/lenore
|
- build/lenore
|
||||||
cmds:
|
cmds:
|
||||||
|
|
|
||||||
8
app.go
8
app.go
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"codeberg.org/danjones000/lenore/config"
|
"codeberg.org/danjones000/lenore/config"
|
||||||
|
"codeberg.org/danjones000/lenore/store"
|
||||||
vocab "github.com/go-ap/activitypub"
|
vocab "github.com/go-ap/activitypub"
|
||||||
"github.com/go-ap/client"
|
"github.com/go-ap/client"
|
||||||
boxap "github.com/go-ap/fedbox/activitypub"
|
boxap "github.com/go-ap/fedbox/activitypub"
|
||||||
proc "github.com/go-ap/processing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
|
|
@ -16,11 +16,11 @@ type App struct {
|
||||||
self vocab.Service
|
self vocab.Service
|
||||||
user vocab.Person
|
user vocab.Person
|
||||||
version string
|
version string
|
||||||
storage proc.Store
|
storage store.Store
|
||||||
client client.C
|
client client.C
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewApp(ver string, conf config.Config, db proc.Store) (*App, error) {
|
func NewApp(ver string, conf config.Config, db store.Store) (*App, error) {
|
||||||
if conf.BaseURL == "" {
|
if conf.BaseURL == "" {
|
||||||
return nil, errors.New("Missing BaseURL")
|
return nil, errors.New("Missing BaseURL")
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ func (l *App) Environment() config.Env {
|
||||||
return l.conf.Environment()
|
return l.conf.Environment()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *App) Storage() proc.Store {
|
func (l *App) Storage() store.Store {
|
||||||
return l.storage
|
return l.storage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
package testmocks
|
package testmocks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"codeberg.org/danjones000/lenore/store"
|
||||||
vocab "github.com/go-ap/activitypub"
|
vocab "github.com/go-ap/activitypub"
|
||||||
"github.com/go-ap/filters"
|
"github.com/go-ap/filters"
|
||||||
proc "github.com/go-ap/processing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type st struct{}
|
type st struct{}
|
||||||
|
|
@ -33,6 +33,9 @@ func (s *st) RemoveFrom(col vocab.IRI, it vocab.Item) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStore() proc.Store {
|
func (s *st) Close() {
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStore() store.Store {
|
||||||
return &st{}
|
return &st{}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
internal/testmocks/store_meta.go
Normal file
20
internal/testmocks/store_meta.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
package testmocks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto"
|
||||||
|
|
||||||
|
vocab "github.com/go-ap/activitypub"
|
||||||
|
proc "github.com/go-ap/processing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *st) LoadKey(vocab.IRI) (crypto.PrivateKey, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) LoadMetadata(vocab.IRI) (*proc.Metadata, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) SaveMetadata(proc.Metadata, vocab.IRI) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
37
internal/testmocks/store_osin_auth.go
Normal file
37
internal/testmocks/store_osin_auth.go
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
package testmocks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/openshift/osin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *st) LoadAccess(string) (*osin.AccessData, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) SaveAccess(*osin.AccessData) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) RemoveAccess(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) LoadAuthorize(string) (*osin.AuthorizeData, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) SaveAuthorize(*osin.AuthorizeData) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) RemoveAuthorize(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) LoadRefresh(string) (*osin.AccessData, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) RemoveRefresh(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
30
internal/testmocks/store_osin_client.go
Normal file
30
internal/testmocks/store_osin_client.go
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
package testmocks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/openshift/osin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *st) Clone() osin.Storage {
|
||||||
|
n := *s
|
||||||
|
return &n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) GetClient(string) (osin.Client, error) {
|
||||||
|
return &osin.DefaultClient{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) CreateClient(osin.Client) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) UpdateClient(osin.Client) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) RemoveClient(string) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *st) ListClients() (cl []osin.Client, er error) {
|
||||||
|
return
|
||||||
|
}
|
||||||
31
store/store.go
Normal file
31
store/store.go
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
package store
|
||||||
|
|
||||||
|
import (
|
||||||
|
st "github.com/go-ap/fedbox/storage"
|
||||||
|
proc "github.com/go-ap/processing"
|
||||||
|
"github.com/openshift/osin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ClientSaver interface {
|
||||||
|
// UpdateClient updates the client (identified by it's id) and replaces the values with the values of client.
|
||||||
|
UpdateClient(c osin.Client) error
|
||||||
|
// CreateClient stores the client in the database and returns an error, if something went wrong.
|
||||||
|
CreateClient(c osin.Client) error
|
||||||
|
// RemoveClient removes a client (identified by id) from the database. Returns an error if something went wrong.
|
||||||
|
RemoveClient(id string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type ClientLister interface {
|
||||||
|
// ListClients lists existing clients
|
||||||
|
ListClients() ([]osin.Client, error)
|
||||||
|
GetClient(id string) (osin.Client, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Store interface {
|
||||||
|
ClientSaver
|
||||||
|
ClientLister
|
||||||
|
proc.Store
|
||||||
|
proc.KeyLoader
|
||||||
|
osin.Storage
|
||||||
|
st.MetadataTyper
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue