Compare commits
68 Commits
data-migra
...
master
Author | SHA1 | Date | |
---|---|---|---|
d2f75c693a | |||
363c35efed | |||
0f361a065b | |||
|
4d1045a9f9 | ||
|
f3a6485bb3 | ||
cd37adc288 | |||
6f0994d692 | |||
|
fbaba15776 | ||
|
9a094f440f | ||
6c77ff58ab | |||
c8ddafcf66 | |||
5f1a659789 | |||
0d4be0f7fc | |||
b6161da749 | |||
f1c4d5f1f9 | |||
73b876dbdd | |||
18e865ba26 | |||
d7c909f028 | |||
908a52cda6 | |||
526dc822fb | |||
1249e45d54 | |||
|
99d03e3bc9 | ||
|
1e495763f5 | ||
|
5e83c89e03 | ||
|
1909b60bf4 | ||
|
49335a290f | ||
|
2c8e60e1bb | ||
|
4baacb325d | ||
|
c243edd4c4 | ||
44846c5950 | |||
|
592c57b72d | ||
|
341f0b9cc8 | ||
|
1c911ee73f | ||
|
00b9079a55 | ||
ec6b078de3 | |||
0b4fde9d1e | |||
66be350ad1 | |||
|
156511e499 | ||
|
8b68130ed4 | ||
|
7ab8eef623 | ||
7d513ac2a7 | |||
fbee26da08 | |||
4fb3474b51 | |||
|
b31011b390 | ||
|
358567e52e | ||
9c05e0b4a2 | |||
57fb1d0ef3 | |||
2dcec2e9fb | |||
286a72f12e | |||
|
933943636e | ||
1e69f2167a | |||
4e584cea92 | |||
|
20feef4103 | ||
|
8d5d3f1dc8 | ||
|
0f54ab4b4a | ||
|
be47c999ca | ||
|
c719db8b92 | ||
|
16cb2846b7 | ||
|
bc2abc2464 | ||
f435046385 | |||
efaf0ab22e | |||
e29bcb5b27 | |||
cdb22f8cbb | |||
|
9cb9e02442 | ||
6aa4bd8906 | |||
|
ab03e6d529 | ||
|
9b66146ef1 | ||
|
825c06c3bb |
16
.dockerignore
Normal file
16
.dockerignore
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
!/args
|
||||||
|
!/cmd/africastalking
|
||||||
|
!/cmd/ssh
|
||||||
|
!/config
|
||||||
|
!/debug
|
||||||
|
!/handlers
|
||||||
|
!/internal
|
||||||
|
!/profile
|
||||||
|
!/services
|
||||||
|
!/ssh
|
||||||
|
!/store
|
||||||
|
!/LICENSE
|
||||||
|
!/README.md
|
||||||
|
!/go.*
|
||||||
|
!/.env.example
|
@ -18,3 +18,6 @@ DATA_URL_BASE=http://localhost:5006
|
|||||||
#Language
|
#Language
|
||||||
DEFAULT_LANGUAGE=eng
|
DEFAULT_LANGUAGE=eng
|
||||||
LANGUAGES=eng, swa
|
LANGUAGES=eng, swa
|
||||||
|
|
||||||
|
#Alias search domains
|
||||||
|
ALIAS_SEARCH_DOMAINS=sarafu.local, sarafu.eth
|
||||||
|
56
.github/workflows/docker.yaml
vendored
Normal file
56
.github/workflows/docker.yaml
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v2
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to GHCR Docker registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.repository_owner }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
run: |
|
||||||
|
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV \
|
||||||
|
&& echo "RELEASE_SHORT_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
build-args: |
|
||||||
|
BUILD=${{ env.RELEASE_SHORT_COMMIT }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
tags: |
|
||||||
|
ghcr.io/grassrootseconomics/sarafu-vise:latest
|
||||||
|
ghcr.io/grassrootseconomics/sarafu-vise:${{ env.RELEASE_TAG }}
|
50
Dockerfile
Normal file
50
Dockerfile
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
FROM golang:1.23.4-bookworm AS build
|
||||||
|
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
|
|
||||||
|
ARG BUILDPLATFORM
|
||||||
|
ARG TARGETPLATFORM
|
||||||
|
ARG BUILD=dev
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libgdbm-dev \
|
||||||
|
git \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN git clone https://git.defalsify.org/vise.git go-vise
|
||||||
|
COPY . ./sarafu-vise
|
||||||
|
|
||||||
|
WORKDIR /build/sarafu-vise/services/registration
|
||||||
|
RUN echo "Compiling go-vise files"
|
||||||
|
RUN make VISE_PATH=/build/go-vise -B
|
||||||
|
|
||||||
|
WORKDIR /build/sarafu-vise
|
||||||
|
RUN echo "Building on $BUILDPLATFORM, building for $TARGETPLATFORM"
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -tags logtrace,online -o sarafu-at -ldflags="-X main.build=${BUILD} -s -w" cmd/africastalking/main.go
|
||||||
|
RUN go build -tags logtrace,online -o sarafu-ssh -ldflags="-X main.build=${BUILD} -s -w" cmd/ssh/main.go
|
||||||
|
|
||||||
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
libgdbm-dev \
|
||||||
|
ca-certificates \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /service
|
||||||
|
|
||||||
|
COPY --from=build /build/sarafu-vise/sarafu-at .
|
||||||
|
COPY --from=build /build/sarafu-vise/sarafu-ssh .
|
||||||
|
COPY --from=build /build/sarafu-vise/LICENSE .
|
||||||
|
COPY --from=build /build/sarafu-vise/README.md .
|
||||||
|
COPY --from=build /build/sarafu-vise/services ./services
|
||||||
|
COPY --from=build /build/sarafu-vise/.env.example .
|
||||||
|
RUN mv .env.example .env
|
||||||
|
|
||||||
|
EXPOSE 7123
|
||||||
|
EXPOSE 7122
|
||||||
|
|
||||||
|
CMD ["./sarafu-at"]
|
10
args/lang.go
10
args/lang.go
@ -10,7 +10,7 @@ type LangVar struct {
|
|||||||
v []lang.Language
|
v []lang.Language
|
||||||
}
|
}
|
||||||
|
|
||||||
func(lv *LangVar) Set(s string) error {
|
func (lv *LangVar) Set(s string) error {
|
||||||
v, err := lang.LanguageFromCode(s)
|
v, err := lang.LanguageFromCode(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -19,16 +19,14 @@ func(lv *LangVar) Set(s string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func(lv *LangVar) String() string {
|
func (lv *LangVar) String() string {
|
||||||
var s []string
|
var s []string
|
||||||
for _, v := range(lv.v) {
|
for _, v := range lv.v {
|
||||||
s = append(s, v.Code)
|
s = append(s, v.Code)
|
||||||
}
|
}
|
||||||
return strings.Join(s, ",")
|
return strings.Join(s, ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
func(lv *LangVar) Langs() []lang.Language {
|
func (lv *LangVar) Langs() []lang.Language {
|
||||||
return lv.v
|
return lv.v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,18 +12,18 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.defalsify.org/vise.git/lang"
|
"git.defalsify.org/vise.git/lang"
|
||||||
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||||
|
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -36,8 +36,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var resourceDir string
|
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var host string
|
var host string
|
||||||
@ -46,10 +45,11 @@ func main() {
|
|||||||
var gettextDir string
|
var gettextDir string
|
||||||
var langs args.LangVar
|
var langs args.LangVar
|
||||||
|
|
||||||
|
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||||
flag.UintVar(&port, "p", config.Port(), "http port")
|
flag.UintVar(&port, "p", config.Port(), "http port")
|
||||||
@ -57,16 +57,14 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "build", build, "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
logg.Infof("start command", "build", build, "conn", conns, "outputsize", size)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ln, err := lang.LanguageFromCode(config.Language())
|
ln, err := lang.LanguageFromCode(config.Language())
|
||||||
@ -89,7 +87,7 @@ func main() {
|
|||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
rs, err := menuStorageService.GetResource(ctx)
|
rs, err := menuStorageService.GetResource(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "menustorageservice: %v\n", err)
|
fmt.Fprintf(os.Stderr, "menustorageservice: %v\n", err)
|
||||||
@ -101,7 +99,6 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "userdatadb: %v\n", err)
|
fmt.Fprintf(os.Stderr, "userdatadb: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer userdataStore.Close()
|
|
||||||
|
|
||||||
dbResource, ok := rs.(*resource.DbResource)
|
dbResource, ok := rs.(*resource.DbResource)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -120,8 +117,8 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService, connData)
|
accountService := services.New(ctx, menuStorageService)
|
||||||
|
|
||||||
hl, err := lhs.GetHandler(accountService)
|
hl, err := lhs.GetHandler(accountService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "httpaccountservice: %v\n", err)
|
fmt.Fprintf(os.Stderr, "httpaccountservice: %v\n", err)
|
||||||
@ -133,7 +130,6 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "getstatestore: %v\n", err)
|
fmt.Fprintf(os.Stderr, "getstatestore: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer stateStore.Close()
|
|
||||||
|
|
||||||
rp := &at.ATRequestParser{}
|
rp := &at.ATRequestParser{}
|
||||||
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||||
@ -146,7 +142,10 @@ func main() {
|
|||||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
s.RegisterOnShutdown(sh.Shutdown)
|
shutdownFunc := func() {
|
||||||
|
sh.Shutdown(ctx)
|
||||||
|
}
|
||||||
|
s.RegisterOnShutdown(shutdownFunc)
|
||||||
|
|
||||||
cint := make(chan os.Signal)
|
cint := make(chan os.Signal)
|
||||||
cterm := make(chan os.Signal)
|
cterm := make(chan os.Signal)
|
||||||
|
@ -14,12 +14,12 @@ import (
|
|||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -44,9 +44,8 @@ func (p *asyncRequestParser) GetInput(r any) ([]byte, error) {
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var sessionId string
|
var sessionId string
|
||||||
var resourceDir string
|
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var host string
|
var host string
|
||||||
@ -56,8 +55,11 @@ func main() {
|
|||||||
var langs args.LangVar
|
var langs args.LangVar
|
||||||
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
|
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||||
@ -66,16 +68,14 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size, "sessionId", sessionId)
|
logg.Infof("start command", "conn", conns, "outputsize", size, "sessionId", sessionId)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ func main() {
|
|||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -116,7 +116,7 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer userdataStore.Close()
|
//defer userdataStore.Close(ctx)
|
||||||
|
|
||||||
dbResource, ok := rs.(*resource.DbResource)
|
dbResource, ok := rs.(*resource.DbResource)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -126,7 +126,7 @@ func main() {
|
|||||||
lhs, err := handlers.NewLocalHandlerService(ctx, pfp, true, dbResource, cfg, rs)
|
lhs, err := handlers.NewLocalHandlerService(ctx, pfp, true, dbResource, cfg, rs)
|
||||||
lhs.SetDataStore(&userdataStore)
|
lhs.SetDataStore(&userdataStore)
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService, connData)
|
accountService := services.New(ctx, menuStorageService)
|
||||||
|
|
||||||
hl, err := lhs.GetHandler(accountService)
|
hl, err := lhs.GetHandler(accountService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -139,7 +139,7 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer stateStore.Close()
|
//defer stateStore.Close(ctx)
|
||||||
|
|
||||||
rp := &asyncRequestParser{
|
rp := &asyncRequestParser{
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
@ -161,7 +161,7 @@ func main() {
|
|||||||
case _ = <-cint:
|
case _ = <-cint:
|
||||||
case _ = <-cterm:
|
case _ = <-cterm:
|
||||||
}
|
}
|
||||||
sh.Shutdown()
|
sh.Shutdown(ctx)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for true {
|
for true {
|
||||||
@ -177,7 +177,7 @@ func main() {
|
|||||||
fmt.Errorf("error in output: %v", err)
|
fmt.Errorf("error in output: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
rqs, err = sh.Reset(rqs)
|
rqs, err = sh.Reset(ctx, rqs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "error in reset: %v", "err", err)
|
logg.ErrorCtxf(ctx, "error in reset: %v", "err", err)
|
||||||
fmt.Errorf("error in reset: %v", err)
|
fmt.Errorf("error in reset: %v", err)
|
||||||
|
@ -17,13 +17,13 @@ import (
|
|||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
|
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -35,8 +35,7 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var resourceDir string
|
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var host string
|
var host string
|
||||||
@ -45,8 +44,11 @@ func main() {
|
|||||||
var gettextDir string
|
var gettextDir string
|
||||||
var langs args.LangVar
|
var langs args.LangVar
|
||||||
|
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
|
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", config.Host(), "http host")
|
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||||
@ -55,16 +57,14 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
logg.Infof("start command", "conn", conns, "outputsize", size)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func main() {
|
|||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
|
|
||||||
rs, err := menuStorageService.GetResource(ctx)
|
rs, err := menuStorageService.GetResource(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -101,7 +101,6 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer userdataStore.Close()
|
|
||||||
|
|
||||||
dbResource, ok := rs.(*resource.DbResource)
|
dbResource, ok := rs.(*resource.DbResource)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -116,8 +115,8 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService, connData)
|
accountService := services.New(ctx, menuStorageService)
|
||||||
|
|
||||||
hl, err := lhs.GetHandler(accountService)
|
hl, err := lhs.GetHandler(accountService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
@ -129,7 +128,6 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer stateStore.Close()
|
|
||||||
|
|
||||||
//accountService := services.New(ctx, menuStorageService, connData)
|
//accountService := services.New(ctx, menuStorageService, connData)
|
||||||
|
|
||||||
@ -140,7 +138,10 @@ func main() {
|
|||||||
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
Addr: fmt.Sprintf("%s:%s", host, strconv.Itoa(int(port))),
|
||||||
Handler: sh,
|
Handler: sh,
|
||||||
}
|
}
|
||||||
s.RegisterOnShutdown(sh.Shutdown)
|
shutdownFunc := func() {
|
||||||
|
sh.Shutdown(ctx)
|
||||||
|
}
|
||||||
|
s.RegisterOnShutdown(shutdownFunc)
|
||||||
|
|
||||||
cint := make(chan os.Signal)
|
cint := make(chan os.Signal)
|
||||||
cterm := make(chan os.Signal)
|
cterm := make(chan os.Signal)
|
||||||
|
50
cmd/main.go
50
cmd/main.go
@ -5,17 +5,19 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
|
"git.defalsify.org/vise.git/lang"
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
"git.defalsify.org/vise.git/lang"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -27,34 +29,33 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var size uint
|
var size uint
|
||||||
var sessionId string
|
var sessionId string
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var resourceDir string
|
|
||||||
var err error
|
var err error
|
||||||
var gettextDir string
|
var gettextDir string
|
||||||
var langs args.LangVar
|
var langs args.LangVar
|
||||||
|
|
||||||
flag.StringVar(&resourceDir, "resourcedir", scriptDir, "resource dir")
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&gettextDir, "gettext", "", "use gettext translations from given directory")
|
flag.StringVar(&gettextDir, "gettext", "", "use gettext translations from given directory")
|
||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v\n", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData, "outputsize", size)
|
logg.Infof("start command", "conn", conns, "outputsize", size)
|
||||||
|
|
||||||
if len(langs.Langs()) == 0 {
|
if len(langs.Langs()) == 0 {
|
||||||
langs.Set(config.Language())
|
langs.Set(config.Language())
|
||||||
@ -80,12 +81,12 @@ func main() {
|
|||||||
MenuSeparator: menuSeparator,
|
MenuSeparator: menuSeparator,
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gettextDir != "" {
|
if gettextDir != "" {
|
||||||
menuStorageService = menuStorageService.WithGettext(gettextDir, langs.Langs())
|
menuStorageService = menuStorageService.WithGettext(gettextDir, langs.Langs())
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService, connData)
|
accountService := services.New(ctx, menuStorageService)
|
||||||
hl, err := lhs.GetHandler(accountService)
|
hl, err := lhs.GetHandler(accountService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "get accounts service handler: %v\n", err)
|
fmt.Fprintf(os.Stderr, "get accounts service handler: %v\n", err)
|
||||||
@ -135,6 +136,21 @@ func main() {
|
|||||||
en = en.WithDebug(nil)
|
en = en.WithDebug(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cint := make(chan os.Signal)
|
||||||
|
cterm := make(chan os.Signal)
|
||||||
|
signal.Notify(cint, os.Interrupt, syscall.SIGINT)
|
||||||
|
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
|
var s os.Signal
|
||||||
|
select {
|
||||||
|
case s = <-cterm:
|
||||||
|
case s = <-cint:
|
||||||
|
}
|
||||||
|
logg.InfoCtxf(ctx, "stopping on signal", "sig", s)
|
||||||
|
en.Finish(ctx)
|
||||||
|
os.Exit(0)
|
||||||
|
}()
|
||||||
|
|
||||||
err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil)
|
err = engine.Loop(ctx, en, os.Stdin, os.Stdout, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
||||||
|
@ -31,34 +31,31 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var authConnStr string
|
var authConnStr string
|
||||||
var resourceDir string
|
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var stateDebug bool
|
var stateDebug bool
|
||||||
var host string
|
var host string
|
||||||
var port uint
|
var port uint
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
|
||||||
flag.StringVar(&authConnStr, "authdb", "", "auth connection string")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource connection string")
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.UintVar(&size, "s", 160, "max size of output")
|
flag.UintVar(&size, "s", 160, "max size of output")
|
||||||
flag.StringVar(&host, "h", config.HostSSH(), "socket host")
|
flag.StringVar(&host, "h", config.HostSSH(), "socket host")
|
||||||
flag.UintVar(&port, "p", config.PortSSH(), "socket port")
|
flag.UintVar(&port, "p", config.PortSSH(), "socket port")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr == "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
if authConnStr == "" {
|
|
||||||
authConnStr = connStr
|
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
authConnData, err := storage.ToConnData(authConnStr)
|
authConnData, err := storage.ToConnData(authConnStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "auth connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "auth connstr err: %v", err)
|
||||||
@ -79,7 +76,7 @@ func main() {
|
|||||||
logg.WarnCtxf(ctx, "!!!!! Do not expose to internet and only use with tunnel!")
|
logg.WarnCtxf(ctx, "!!!!! Do not expose to internet and only use with tunnel!")
|
||||||
logg.WarnCtxf(ctx, "!!!!! (See ssh -L <...>)")
|
logg.WarnCtxf(ctx, "!!!!! (See ssh -L <...>)")
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData, "authconn", authConnData, "resourcedir", resourceDir, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
logg.Infof("start command", "conn", conns, "authconn", authConnData, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
||||||
|
|
||||||
pfp := path.Join(scriptDir, "pp.csv")
|
pfp := path.Join(scriptDir, "pp.csv")
|
||||||
|
|
||||||
@ -102,7 +99,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
logg.TraceCtxf(ctx, "shutdown auth key store reached")
|
logg.TraceCtxf(ctx, "shutdown auth key store reached")
|
||||||
err = authKeyStore.Close()
|
err = authKeyStore.Close(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "keystore close error", "err", err)
|
logg.ErrorCtxf(ctx, "keystore close error", "err", err)
|
||||||
}
|
}
|
||||||
@ -114,14 +111,13 @@ func main() {
|
|||||||
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(cterm, os.Interrupt, syscall.SIGTERM)
|
||||||
|
|
||||||
runner := &ssh.SshRunner{
|
runner := &ssh.SshRunner{
|
||||||
Cfg: cfg,
|
Cfg: cfg,
|
||||||
Debug: engineDebug,
|
Debug: engineDebug,
|
||||||
FlagFile: pfp,
|
FlagFile: pfp,
|
||||||
Conn: connData,
|
Conn: conns,
|
||||||
ResourceDir: resourceDir,
|
SrvKeyFile: sshKeyFile,
|
||||||
SrvKeyFile: sshKeyFile,
|
Host: host,
|
||||||
Host: host,
|
Port: port,
|
||||||
Port: port,
|
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
select {
|
select {
|
||||||
|
@ -34,7 +34,7 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, "%v\n", err)
|
fmt.Fprintf(os.Stderr, "%v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer store.Close()
|
defer store.Close(ctx)
|
||||||
|
|
||||||
err = store.AddFromFile(ctx, sshKeyFile, sessionId)
|
err = store.AddFromFile(ctx, sshKeyFile, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
20
config/args.go
Normal file
20
config/args.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewOverride() *viseconfig.Override {
|
||||||
|
o := &viseconfig.Override{
|
||||||
|
StateConnMode: storage.DBMODE_TEXT,
|
||||||
|
ResourceConnMode: storage.DBMODE_TEXT,
|
||||||
|
UserConnMode: storage.DBMODE_BINARY,
|
||||||
|
}
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
func Apply(o *viseconfig.Override) error {
|
||||||
|
viseconfig.ApplyConn(o)
|
||||||
|
return nil
|
||||||
|
}
|
@ -1,24 +1,36 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
"strings"
|
||||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
|
||||||
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||||
|
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
var (
|
||||||
env.LoadEnvVariables()
|
GetConns = viseconfig.GetConns
|
||||||
|
EnvPath string
|
||||||
|
)
|
||||||
|
|
||||||
|
func loadEnv() {
|
||||||
|
if EnvPath == "" {
|
||||||
|
env.LoadEnvVariables()
|
||||||
|
} else {
|
||||||
|
env.LoadEnvVariablesPath(EnvPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultSSHHost string = "127.0.0.1"
|
defaultSSHHost string = "127.0.0.1"
|
||||||
defaultSSHPort uint = 7122
|
defaultSSHPort uint = 7122
|
||||||
defaultHTTPHost string = "127.0.0.1"
|
defaultHTTPHost string = "127.0.0.1"
|
||||||
defaultHTTPPort uint = 7123
|
defaultHTTPPort uint = 7123
|
||||||
|
defaultDomain = "sarafu.local"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func LoadConfig() error {
|
func LoadConfig() error {
|
||||||
|
loadEnv()
|
||||||
err := viseconfig.LoadConfig()
|
err := viseconfig.LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -30,10 +42,17 @@ func LoadConfig() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DbConn() string {
|
func SearchDomains() []string {
|
||||||
return viseconfig.DbConn
|
var ParsedDomains []string
|
||||||
|
SearchDomains := env.GetEnv("ALIAS_SEARCH_DOMAINS", defaultDomain)
|
||||||
|
SearchDomainList := strings.Split(env.GetEnv("ALIAS_SEARCH_DOMAINS", SearchDomains), ",")
|
||||||
|
for _, domain := range SearchDomainList {
|
||||||
|
ParsedDomains = append(ParsedDomains, strings.ReplaceAll(domain, " ", ""))
|
||||||
|
}
|
||||||
|
return ParsedDomains
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Language() string {
|
func Language() string {
|
||||||
return viseconfig.DefaultLanguage
|
return viseconfig.DefaultLanguage
|
||||||
}
|
}
|
||||||
|
41
debug/db.go
41
debug/db.go
@ -1,11 +1,11 @@
|
|||||||
package debug
|
package debug
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
|
||||||
visedb "git.defalsify.org/vise.git/db"
|
visedb "git.defalsify.org/vise.git/db"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -13,10 +13,10 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type KeyInfo struct {
|
type KeyInfo struct {
|
||||||
SessionId string
|
SessionId string
|
||||||
Typ uint8
|
Typ uint8
|
||||||
SubTyp storedb.DataTyp
|
SubTyp storedb.DataTyp
|
||||||
Label string
|
Label string
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,18 +32,10 @@ func (k KeyInfo) String() string {
|
|||||||
|
|
||||||
func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
|
func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
|
||||||
o := KeyInfo{}
|
o := KeyInfo{}
|
||||||
b := []byte(sessionId)
|
|
||||||
|
|
||||||
if len(k) <= len(b) {
|
|
||||||
return o, fmt.Errorf("storage key missing")
|
|
||||||
}
|
|
||||||
|
|
||||||
o.SessionId = sessionId
|
o.SessionId = sessionId
|
||||||
|
|
||||||
o.Typ = uint8(k[0])
|
o.Typ = uint8(k[0])
|
||||||
k = k[1:]
|
k = k[1:]
|
||||||
o.SessionId = string(k[:len(b)])
|
|
||||||
k = k[len(b):]
|
|
||||||
|
|
||||||
if o.Typ == visedb.DATATYPE_USERDATA {
|
if o.Typ == visedb.DATATYPE_USERDATA {
|
||||||
if len(k) == 0 {
|
if len(k) == 0 {
|
||||||
@ -53,30 +45,19 @@ func ToKeyInfo(k []byte, sessionId string) (KeyInfo, error) {
|
|||||||
o.SubTyp = storedb.DataTyp(v)
|
o.SubTyp = storedb.DataTyp(v)
|
||||||
o.Label = subTypToString(o.SubTyp)
|
o.Label = subTypToString(o.SubTyp)
|
||||||
k = k[2:]
|
k = k[2:]
|
||||||
|
if len(k) != 0 {
|
||||||
|
return o, fmt.Errorf("excess key information: %x", k)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
o.Label = typToString(o.Typ)
|
o.Label = typToString(o.Typ)
|
||||||
}
|
k = k[2:]
|
||||||
|
|
||||||
if len(k) != 0 {
|
|
||||||
return o, fmt.Errorf("excess key information")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return o, nil
|
return o, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func FromKey(k []byte) (KeyInfo, error) {
|
|
||||||
o := KeyInfo{}
|
|
||||||
|
|
||||||
if len(k) < 4 {
|
|
||||||
return o, fmt.Errorf("insufficient key length")
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionIdBytes := k[1:len(k)-2]
|
|
||||||
return ToKeyInfo(k, string(sessionIdBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
func subTypToString(v storedb.DataTyp) string {
|
func subTypToString(v storedb.DataTyp) string {
|
||||||
return dbTypStr[v + visedb.DATATYPE_USERDATA + 1]
|
return dbTypStr[v+visedb.DATATYPE_USERDATA+1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func typToString(v uint8) string {
|
func typToString(v uint8) string {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
//go:build debugdb
|
||||||
// +build debugdb
|
// +build debugdb
|
||||||
|
|
||||||
package debug
|
package debug
|
||||||
@ -11,34 +12,37 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
DebugCap |= 1
|
DebugCap |= 1
|
||||||
dbTypStr[db.DATATYPE_STATE] = "internal state"
|
dbTypStr[db.DATATYPE_STATE] = "internal state"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TRACKING_ID] = "tracking id"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TRACKING_ID] = "tracking id"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY] = "public key"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY] = "public key"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACCOUNT_PIN] = "account pin"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACCOUNT_PIN] = "account pin"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FIRST_NAME] = "first name"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FIRST_NAME] = "first name"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_FAMILY_NAME] = "family name"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_FAMILY_NAME] = "family name"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_YOB] = "year of birth"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_YOB] = "year of birth"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_LOCATION] = "location"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_LOCATION] = "location"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_GENDER] = "gender"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_GENDER] = "gender"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_OFFERINGS] = "offerings"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_OFFERINGS] = "offerings"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_RECIPIENT] = "recipient"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_RECIPIENT] = "recipient"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_AMOUNT] = "amount"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_AMOUNT] = "amount"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TEMPORARY_VALUE] = "temporary value"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TEMPORARY_VALUE] = "temporary value"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_SYM] = "active sym"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_SYM] = "active sym"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_BAL] = "active bal"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_BAL] = "active bal"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_BLOCKED_NUMBER] = "blocked number"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_BLOCKED_NUMBER] = "blocked number"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_PUBLIC_KEY_REVERSE] = "public_key_reverse"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_DECIMAL] = "active decimal"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_ACTIVE_ADDRESS] = "active address"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_ACTIVE_ADDRESS] = "active address"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INCORRECT_PIN_ATTEMPTS] = "incorrect pin attempts"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_SELECTED_LANGUAGE_CODE] = "selected language"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INITIAL_LANGUAGE_CODE] = "initial language"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SENDERS] = "tx senders"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_VALUES] = "tx values"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SENDERS] = "tx senders"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_HASHES] = "tx hashes"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DATES] = "tx dates"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_VALUES] = "tx values"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SYMBOLS] = "tx symbols"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
||||||
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DECIMALS] = "tx decimals"
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_HASHES] = "tx hashes"
|
||||||
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DATES] = "tx dates"
|
||||||
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SYMBOLS] = "tx symbols"
|
||||||
|
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_DECIMALS] = "tx decimals"
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,13 @@ package debug
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
|
||||||
visedb "git.defalsify.org/vise.git/db"
|
visedb "git.defalsify.org/vise.git/db"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDebugDbSubKeyInfo(t *testing.T) {
|
func TestDebugDbSubKeyInfo(t *testing.T) {
|
||||||
s := "foo"
|
s := "foo"
|
||||||
b := []byte{0x20}
|
b := []byte{0x20}
|
||||||
b = append(b, []byte(s)...)
|
|
||||||
b = append(b, []byte{0x00, 0x02}...)
|
b = append(b, []byte{0x00, 0x02}...)
|
||||||
r, err := ToKeyInfo(b, s)
|
r, err := ToKeyInfo(b, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -25,7 +24,7 @@ func TestDebugDbSubKeyInfo(t *testing.T) {
|
|||||||
if r.SubTyp != 2 {
|
if r.SubTyp != 2 {
|
||||||
t.Fatalf("expected 2, got %d", r.SubTyp)
|
t.Fatalf("expected 2, got %d", r.SubTyp)
|
||||||
}
|
}
|
||||||
if DebugCap & 1 > 0 {
|
if DebugCap&1 > 0 {
|
||||||
if r.Label != "tracking id" {
|
if r.Label != "tracking id" {
|
||||||
t.Fatalf("expected 'tracking id', got '%s'", r.Label)
|
t.Fatalf("expected 'tracking id', got '%s'", r.Label)
|
||||||
}
|
}
|
||||||
@ -46,7 +45,7 @@ func TestDebugDbKeyInfo(t *testing.T) {
|
|||||||
if r.Typ != 16 {
|
if r.Typ != 16 {
|
||||||
t.Fatalf("expected 16, got %d", r.Typ)
|
t.Fatalf("expected 16, got %d", r.Typ)
|
||||||
}
|
}
|
||||||
if DebugCap & 1 > 0 {
|
if DebugCap&1 > 0 {
|
||||||
if r.Label != "internal state" {
|
if r.Label != "internal state" {
|
||||||
t.Fatalf("expected 'internal_state', got '%s'", r.Label)
|
t.Fatalf("expected 'internal_state', got '%s'", r.Label)
|
||||||
}
|
}
|
||||||
@ -56,7 +55,6 @@ func TestDebugDbKeyInfo(t *testing.T) {
|
|||||||
func TestDebugDbKeyInfoRestore(t *testing.T) {
|
func TestDebugDbKeyInfoRestore(t *testing.T) {
|
||||||
s := "bar"
|
s := "bar"
|
||||||
b := []byte{visedb.DATATYPE_USERDATA}
|
b := []byte{visedb.DATATYPE_USERDATA}
|
||||||
b = append(b, []byte(s)...)
|
|
||||||
k := storedb.ToBytes(storedb.DATA_ACTIVE_SYM)
|
k := storedb.ToBytes(storedb.DATA_ACTIVE_SYM)
|
||||||
b = append(b, k...)
|
b = append(b, k...)
|
||||||
|
|
||||||
@ -70,7 +68,7 @@ func TestDebugDbKeyInfoRestore(t *testing.T) {
|
|||||||
if r.Typ != 32 {
|
if r.Typ != 32 {
|
||||||
t.Fatalf("expected 32, got %d", r.Typ)
|
t.Fatalf("expected 32, got %d", r.Typ)
|
||||||
}
|
}
|
||||||
if DebugCap & 1 > 0 {
|
if DebugCap&1 > 0 {
|
||||||
if r.Label != "active sym" {
|
if r.Label != "active sym" {
|
||||||
t.Fatalf("expected 'active sym', got '%s'", r.Label)
|
t.Fatalf("expected 'active sym', got '%s'", r.Label)
|
||||||
}
|
}
|
||||||
|
@ -10,35 +10,37 @@ import (
|
|||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logg = logging.NewVanilla().WithContextKey("SessionId")
|
logg = logging.NewVanilla().WithContextKey("SessionId")
|
||||||
scriptDir = path.Join("services", "registration")
|
scriptDir = path.Join("services", "registration")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
|
override := config.NewOverride()
|
||||||
var sessionId string
|
var sessionId string
|
||||||
var connStr string
|
|
||||||
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
config.Apply(override)
|
||||||
if connStr == "" {
|
conns, err := config.GetConns()
|
||||||
connStr = config.DbConn()
|
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v\n", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
|
|
||||||
@ -49,16 +51,16 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
x := cmd.NewCmd(connData, sessionId, flagParser)
|
x := cmd.NewCmd(sessionId, flagParser)
|
||||||
err = x.Parse(flag.Args())
|
err = x.Parse(flag.Args())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "cmd parse fail: %v\n", err)
|
fmt.Fprintf(os.Stderr, "cmd parse fail: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData, "subcmd", x)
|
logg.Infof("start command", "conn", conns, "subcmd", x)
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, "")
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -8,18 +8,17 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.defalsify.org/vise.git/lang"
|
"git.defalsify.org/vise.git/lang"
|
||||||
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
"git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
||||||
changeHeadSrc = `LOAD reset_account_authorized 0
|
changeHeadSrc = `LOAD reset_account_authorized 0
|
||||||
LOAD reset_incorrect 0
|
LOAD reset_incorrect 0
|
||||||
CATCH incorrect_pin flag_incorrect_pin 1
|
CATCH incorrect_pin flag_incorrect_pin 1
|
||||||
CATCH pin_entry flag_account_authorized 0
|
CATCH pin_entry flag_account_authorized 0
|
||||||
`
|
`
|
||||||
|
|
||||||
selectSrc = `LOAD set_language 6
|
selectSrc = `LOAD set_language 6
|
||||||
RELOAD set_language
|
RELOAD set_language
|
||||||
@ -29,8 +28,8 @@ MOVE language_changed
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logg = logging.NewVanilla()
|
logg = logging.NewVanilla()
|
||||||
mouts string
|
mouts string
|
||||||
incmps string
|
incmps string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
logg.Tracef("using languages", "lang", config.Languages)
|
logg.Tracef("using languages", "lang", config.Languages)
|
||||||
|
|
||||||
for i, v := range(config.Languages) {
|
for i, v := range config.Languages {
|
||||||
ln, err := lang.LanguageFromCode(v)
|
ln, err := lang.LanguageFromCode(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error parsing language: %s\n", v)
|
fmt.Fprintf(os.Stderr, "error parsing language: %s\n", v)
|
||||||
@ -76,7 +75,7 @@ func main() {
|
|||||||
incmps += fmt.Sprintf("INCMP %s %v\n", v, n)
|
incmps += fmt.Sprintf("INCMP %s %v\n", v, n)
|
||||||
|
|
||||||
p := path.Join(srcDir, v)
|
p := path.Join(srcDir, v)
|
||||||
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed open language set template output: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed open language set template output: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -93,7 +92,7 @@ func main() {
|
|||||||
src += "INCMP . *\n"
|
src += "INCMP . *\n"
|
||||||
|
|
||||||
p := path.Join(srcDir, "select_language.vis")
|
p := path.Join(srcDir, "select_language.vis")
|
||||||
w, err := os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
w, err := os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -107,7 +106,7 @@ func main() {
|
|||||||
|
|
||||||
src = changeHeadSrc + src
|
src = changeHeadSrc + src
|
||||||
p = path.Join(srcDir, "change_language.vis")
|
p = path.Join(srcDir, "change_language.vis")
|
||||||
w, err = os.OpenFile(p, os.O_WRONLY | os.O_CREATE | os.O_EXCL, 0600)
|
w, err = os.OpenFile(p, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed open select language vis output: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/debug"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -19,55 +19,58 @@ var (
|
|||||||
scriptDir = path.Join("services", "registration")
|
scriptDir = path.Join("services", "registration")
|
||||||
)
|
)
|
||||||
|
|
||||||
func formatItem(k []byte, v []byte) (string, error) {
|
func formatItem(k []byte, v []byte, sessionId string) (string, error) {
|
||||||
o, err := debug.FromKey(k)
|
o, err := debug.ToKeyInfo(k, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
s := fmt.Sprintf("%vValue: %v\n\n", o, string(v))
|
s := fmt.Sprintf("%v\t%v\n", o.Label, string(v))
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
var connStr string
|
override := config.NewOverride()
|
||||||
var sessionId string
|
var sessionId string
|
||||||
var database string
|
var database string
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var err error
|
var err error
|
||||||
|
var first bool
|
||||||
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
||||||
flag.StringVar(&connStr, "c", ".state", "connection string")
|
flag.StringVar(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
||||||
|
flag.StringVar(&override.ResourceConn, "resource", "?", "resource data directory")
|
||||||
|
flag.StringVar(&override.UserConn, "userdata", "?", "userdata store connection string")
|
||||||
|
flag.StringVar(&override.StateConn, "state", "?", "state store connection string")
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if connStr != "" {
|
config.Apply(override)
|
||||||
connStr = config.DbConn()
|
conns, err := config.GetConns()
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData)
|
logg.Infof("start command", "conn", conns)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
ctx = context.WithValue(ctx, "Database", database)
|
ctx = context.WithValue(ctx, "Database", database)
|
||||||
|
|
||||||
resourceDir := scriptDir
|
menuStorageService := storage.NewMenuStorageService(conns)
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
|
||||||
|
|
||||||
store, err := menuStorageService.GetUserdataDb(ctx)
|
store, err := menuStorageService.GetUserdataDb(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "get userdata db: %v\n", err.Error())
|
fmt.Fprintf(os.Stderr, "get userdata db: %v\n", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
store.SetSession(sessionId)
|
||||||
store.SetPrefix(db.DATATYPE_USERDATA)
|
store.SetPrefix(db.DATATYPE_USERDATA)
|
||||||
|
|
||||||
d, err := store.Dump(ctx, []byte(sessionId))
|
d, err := store.Dump(ctx, []byte(""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "store dump fail: %v\n", err.Error())
|
fmt.Fprintf(os.Stderr, "store dump fail: %v\n", err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -78,15 +81,19 @@ func main() {
|
|||||||
if k == nil {
|
if k == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
r, err := formatItem(k, v)
|
if !first {
|
||||||
|
fmt.Printf("Session ID: %s\n---\n", sessionId)
|
||||||
|
first = true
|
||||||
|
}
|
||||||
|
r, err := formatItem(append([]byte{db.DATATYPE_USERDATA}, k...), v, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "format db item error: %v", err)
|
fmt.Fprintf(os.Stderr, "format db item error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Printf(r)
|
fmt.Printf(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = store.Close()
|
err = store.Close(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"crypto/sha1"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
testdataloader "github.com/peteole/testdata-loader"
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
logg = logging.NewVanilla()
|
|
||||||
baseDir = testdataloader.GetBasePath()
|
|
||||||
scriptDir = path.Join("services", "registration")
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
config.LoadConfig()
|
|
||||||
|
|
||||||
var connStr string
|
|
||||||
var sessionId string
|
|
||||||
var database string
|
|
||||||
var engineDebug bool
|
|
||||||
var err error
|
|
||||||
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
|
||||||
flag.StringVar(&connStr, "c", "", "connection string")
|
|
||||||
flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
if connStr != "" {
|
|
||||||
connStr = config.DbConn()
|
|
||||||
}
|
|
||||||
connData, err := storage.ToConnData(connStr)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
logg.Infof("start command", "conn", connData)
|
|
||||||
|
|
||||||
ctx := context.Background()
|
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
|
||||||
ctx = context.WithValue(ctx, "Database", database)
|
|
||||||
|
|
||||||
resourceDir := scriptDir
|
|
||||||
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
|
||||||
|
|
||||||
userDb, err := menuStorageService.GetUserdataDb(ctx)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
userStore := store.UserDataStore{userDb}
|
|
||||||
|
|
||||||
h := sha1.New()
|
|
||||||
h.Write([]byte(sessionId))
|
|
||||||
address := h.Sum(nil)
|
|
||||||
addressString := fmt.Sprintf("%x", address)
|
|
||||||
|
|
||||||
err = userStore.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(addressString))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = userStore.WriteEntry(ctx, addressString, storedb.DATA_PUBLIC_KEY_REVERSE, []byte(sessionId))
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = userDb.Close()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
10
go.mod
10
go.mod
@ -3,11 +3,11 @@ module git.grassecon.net/grassrootseconomics/sarafu-vise
|
|||||||
go 1.23.4
|
go 1.23.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739
|
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84
|
||||||
github.com/alecthomas/assert/v2 v2.2.2
|
github.com/alecthomas/assert/v2 v2.2.2
|
||||||
github.com/gofrs/uuid v4.4.0+incompatible
|
github.com/gofrs/uuid v4.4.0+incompatible
|
||||||
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
github.com/grassrootseconomics/ussd-data-service v1.2.0-beta
|
||||||
|
20
go.sum
20
go.sum
@ -1,13 +1,13 @@
|
|||||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739 h1:w7pj1oh7jXrfajahVYU7m7AfHst4C6jNVzDVoaqJ7e8=
|
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 h1:sPcqXQcywxA8W3W+9qQncLPmsrgqTIlec7vmD4/7vyA=
|
||||||
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d h1:5mzLas+jxTUtusOKx4XvU+n2QvrV/mH17MnJRy46siQ=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f h1:FgccQi8vipX6dUt+GRiRDYHMR3UqC+plz73vw7y3fyU=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1 h1:BJHfokTHzrw9QjQ+4s2HmSER0iBPuE7byW5oQC2zLIQ=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f/go.mod h1:tbA4whUGMUIDgQVdIW0sxWPuuXOvZRSny5zeku5hX4k=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1/go.mod h1:gOn89ipaDcDvmQXRMQYKUqcw/sJcwVOPVt2eC6Geip8=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63 h1:bX7klKZpX+ZZu1LKbtOXDAhV/KK0YwExehiIi0jusAM=
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa h1:yQLKwby3eD/zNjNw/INU5lGiLuWPEHdsgASwMA4UptE=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63/go.mod h1:Syw9TZyigPAM7t9FvicOm36iUnidt45f0SxzT2JniQ8=
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d h1:q/NO1rEgK3pia32D/tCq5hXfEuJp84COZRwceFvy/MM=
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d/go.mod h1:AH15xABcvaJr1TCGlih3oGSuwWC0E5IdbHQwuu+E1KI=
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=
|
||||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||||
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
github.com/alecthomas/participle/v2 v2.0.0 h1:Fgrq+MbuSsJwIkw3fEj9h75vDP0Er5JzepJ0/HNHv0g=
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ func InitializeTestStore(t *testing.T) (context.Context, *store.UserDataStore) {
|
|||||||
store := &store.UserDataStore{Db: db}
|
store := &store.UserDataStore{Db: db}
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
db.Close() // Ensure the DB is closed after each test
|
db.Close(ctx) // Ensure the DB is closed after each test
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx, store
|
return ctx, store
|
||||||
@ -265,6 +265,7 @@ func TestWithPersister(t *testing.T) {
|
|||||||
h.SetPersister(p)
|
h.SetPersister(p)
|
||||||
|
|
||||||
assert.Equal(t, p, h.pe, "The persister should be set correctly.")
|
assert.Equal(t, p, h.pe, "The persister should be set correctly.")
|
||||||
|
//assert.Equal(t, h, result, "The returned handler should be the same instance.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWithPersister_PanicWhenAlreadySet(t *testing.T) {
|
func TestWithPersister_PanicWhenAlreadySet(t *testing.T) {
|
||||||
@ -1222,13 +1223,20 @@ func TestVerifyCreatePin(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hash the correct PIN
|
||||||
|
hashedPIN, err := pin.HashPIN("1234")
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to hash temporaryPin", "error", err)
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(hashedPIN))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte("1234"))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the method under test
|
// Call the method under test
|
||||||
res, err := h.VerifyCreatePin(ctx, "verify_create_pin", []byte(tt.input))
|
res, err := h.VerifyCreatePin(ctx, "verify_create_pin", []byte(tt.input))
|
||||||
|
|
||||||
@ -1671,7 +1679,7 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Test with alias recepient",
|
name: "Test with alias recepient",
|
||||||
input: []byte("alias123"),
|
input: []byte("alias123.sarafu.local"),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1789,37 +1797,37 @@ func TestGetProfile(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Test with full profile information in eng",
|
name: "Test with full profile information in eng",
|
||||||
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB, storedb.DATA_ACCOUNT_ALIAS},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
||||||
languageCode: "eng",
|
languageCode: "eng",
|
||||||
result: resource.Result{
|
result: resource.Result{
|
||||||
Content: fmt.Sprintf(
|
Content: fmt.Sprintf(
|
||||||
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\nYour alias: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Test with with profile information in swa",
|
name: "Test with with profile information in swa",
|
||||||
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB, storedb.DATA_ACCOUNT_ALIAS},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
||||||
languageCode: "swa",
|
languageCode: "swa",
|
||||||
result: resource.Result{
|
result: resource.Result{
|
||||||
Content: fmt.Sprintf(
|
Content: fmt.Sprintf(
|
||||||
"Jina: %s\nJinsia: %s\nUmri: %s\nEneo: %s\nUnauza: %s\n",
|
"Jina: %s\nJinsia: %s\nUmri: %s\nEneo: %s\nUnauza: %s\nLakabu yako: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Test with with profile information with language that is not yet supported",
|
name: "Test with with profile information with language that is not yet supported",
|
||||||
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB, storedb.DATA_ACCOUNT_ALIAS},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
||||||
languageCode: "nor",
|
languageCode: "nor",
|
||||||
result: resource.Result{
|
result: resource.Result{
|
||||||
Content: fmt.Sprintf(
|
Content: fmt.Sprintf(
|
||||||
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\nYour alias: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1907,13 +1915,13 @@ func TestConfirmPin(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input []byte
|
input []byte
|
||||||
temporarypin []byte
|
temporarypin string
|
||||||
expectedResult resource.Result
|
expectedResult resource.Result
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "Test with correct pin confirmation",
|
name: "Test with correct pin confirmation",
|
||||||
input: []byte("1234"),
|
input: []byte("1234"),
|
||||||
temporarypin: []byte("1234"),
|
temporarypin: "1234",
|
||||||
expectedResult: resource.Result{
|
expectedResult: resource.Result{
|
||||||
FlagReset: []uint32{flag_pin_mismatch},
|
FlagReset: []uint32{flag_pin_mismatch},
|
||||||
},
|
},
|
||||||
@ -1921,14 +1929,21 @@ func TestConfirmPin(t *testing.T) {
|
|||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
// Hash the PIN
|
||||||
|
hashedPIN, err := pin.HashPIN(tt.temporarypin)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to hash temporaryPin", "error", err)
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
// Set up the expected behavior of the mock
|
// Set up the expected behavior of the mock
|
||||||
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tt.temporarypin))
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(hashedPIN))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Call the function under test
|
//Call the function under test
|
||||||
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.temporarypin)
|
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.input)
|
||||||
|
|
||||||
//Assert that the result set to content is what was expected
|
//Assert that the result set to content is what was expected
|
||||||
assert.Equal(t, res, tt.expectedResult, "Result should contain flags set according to user input")
|
assert.Equal(t, res, tt.expectedResult, "Result should contain flags set according to user input")
|
||||||
|
@ -35,13 +35,6 @@ func (eu *EventsUpdater) HandleCustodialRegistration(ctx context.Context, ev *ap
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// err = pe.Load(identity.SessionId)
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
// st := pe.GetState()
|
|
||||||
// st.SetFlag(accountCreatedFlag)
|
|
||||||
// return pe.Save(identity.SessionId)
|
|
||||||
logg.DebugCtxf(ctx, "received custodial registration event", "identity", identity)
|
logg.DebugCtxf(ctx, "received custodial registration event", "identity", identity)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -17,9 +17,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type EventsUpdater struct {
|
type EventsUpdater struct {
|
||||||
api remote.AccountService
|
api remote.AccountService
|
||||||
formatFunc func(string, int, any) string
|
formatFunc func(string, int, any) string
|
||||||
store storage.StorageService
|
store storage.StorageService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEventsUpdater(api remote.AccountService, store storage.StorageService) *EventsUpdater {
|
func NewEventsUpdater(api remote.AccountService, store storage.StorageService) *EventsUpdater {
|
||||||
|
@ -6,13 +6,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
|
||||||
"git.grassecon.net/grassrootseconomics/common/identity"
|
"git.grassecon.net/grassrootseconomics/common/identity"
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
)
|
)
|
||||||
|
|
||||||
// execute all
|
// execute all
|
||||||
func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, tokenAddress string) error {
|
func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, tokenAddress string) error {
|
||||||
err := eu.updateTokenList(ctx, identity, userStore)
|
err := eu.updateTokenList(ctx, identity, userStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -47,7 +47,6 @@ func (eu *EventsUpdater) updateToken(ctx context.Context, identity identity.Iden
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set default token to given symbol.
|
// set default token to given symbol.
|
||||||
func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, activeSym string) error {
|
func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identity.Identity, userStore *store.UserDataStore, activeSym string) error {
|
||||||
pfxDb := toPrefixDb(userStore, identity.SessionId)
|
pfxDb := toPrefixDb(userStore, identity.SessionId)
|
||||||
@ -59,7 +58,6 @@ func (eu *EventsUpdater) updateDefaultToken(ctx context.Context, identity identi
|
|||||||
return store.UpdateVoucherData(ctx, userStore, identity.SessionId, tokenData)
|
return store.UpdateVoucherData(ctx, userStore, identity.SessionId, tokenData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// handle token transfer.
|
// handle token transfer.
|
||||||
//
|
//
|
||||||
// if from and to are NOT the same, handle code will be executed once for each side of the transfer.
|
// if from and to are NOT the same, handle code will be executed once for each side of the transfer.
|
||||||
@ -189,7 +187,7 @@ func (eu *EventsUpdater) updateTokenTransferList(ctx context.Context, identity i
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tx := range(txs) {
|
for i, tx := range txs {
|
||||||
r = append(r, eu.formatFunc(apievent.EventTokenTransferTag, i, tx))
|
r = append(r, eu.formatFunc(apievent.EventTokenTransferTag, i, tx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,9 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
//appHandlers = appHandlers.WithPersister(ls.Pe)
|
||||||
appHandlers.SetPersister(ls.Pe)
|
appHandlers.SetPersister(ls.Pe)
|
||||||
|
ls.DbRs.AddLocalFunc("check_blocked_status", appHandlers.CheckBlockedStatus)
|
||||||
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
|
ls.DbRs.AddLocalFunc("set_language", appHandlers.SetLanguage)
|
||||||
ls.DbRs.AddLocalFunc("create_account", appHandlers.CreateAccount)
|
ls.DbRs.AddLocalFunc("create_account", appHandlers.CreateAccount)
|
||||||
ls.DbRs.AddLocalFunc("save_temporary_pin", appHandlers.SaveTemporaryPin)
|
ls.DbRs.AddLocalFunc("save_temporary_pin", appHandlers.SaveTemporaryPin)
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -14,18 +14,17 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Cmd struct {
|
type Cmd struct {
|
||||||
sessionId string
|
sessionId string
|
||||||
conn storage.ConnData
|
conn storage.ConnData
|
||||||
flagParser *application.FlagManager
|
flagParser *application.FlagManager
|
||||||
cmd int
|
cmd int
|
||||||
enable bool
|
enable bool
|
||||||
exec func(ctx context.Context, ss storage.StorageService) error
|
exec func(ctx context.Context, ss storage.StorageService) error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmd(conn storage.ConnData, sessionId string, flagParser *application.FlagManager) *Cmd {
|
func NewCmd(sessionId string, flagParser *application.FlagManager) *Cmd {
|
||||||
return &Cmd{
|
return &Cmd{
|
||||||
conn: conn,
|
sessionId: sessionId,
|
||||||
sessionId: sessionId,
|
|
||||||
flagParser: flagParser,
|
flagParser: flagParser,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,5 +94,3 @@ func (c *Cmd) Parse(args []string) error {
|
|||||||
|
|
||||||
return fmt.Errorf("unknown subcommand: %s", cmd)
|
return fmt.Errorf("unknown subcommand: %s", cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "1234",
|
"input": "1234",
|
||||||
"expectedContent": "My profile:\nName: foo bar\nGender: male\nAge: 80\nLocation: Kilifi\nYou provide: Bananas\n\n0:Back\n9:Quit"
|
"expectedContent": "My profile:\nName: foo bar\nGender: male\nAge: 80\nLocation: Kilifi\nYou provide: Bananas\nYour alias: \n\n0:Back\n9:Quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "0",
|
"input": "0",
|
||||||
|
@ -9,12 +9,14 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/gofrs/uuid"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
||||||
|
"github.com/gofrs/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
logg = logging.NewVanilla().WithDomain("menutraversaltest")
|
||||||
testData = driver.ReadData()
|
testData = driver.ReadData()
|
||||||
sessionID string
|
sessionID string
|
||||||
src = rand.NewSource(42)
|
src = rand.NewSource(42)
|
||||||
@ -22,9 +24,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var groupTestFile = flag.String("test-file", "group_test.json", "The test file to use for running the group tests")
|
var groupTestFile = flag.String("test-file", "group_test.json", "The test file to use for running the group tests")
|
||||||
var database = flag.String("db", "gdbm", "Specify the database (gdbm or postgres)")
|
|
||||||
var connStr = flag.String("conn", ".test_state", "connection string")
|
|
||||||
var dbSchema = flag.String("schema", "test", "Specify the database schema (default test)")
|
|
||||||
|
|
||||||
func GenerateSessionId() string {
|
func GenerateSessionId() string {
|
||||||
uu := uuid.NewGenWithOptions(uuid.WithRandomReader(g))
|
uu := uuid.NewGenWithOptions(uuid.WithRandomReader(g))
|
||||||
@ -80,12 +79,7 @@ func extractSendAmount(response []byte) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// Parse the flags
|
|
||||||
flag.Parse()
|
|
||||||
sessionID = GenerateSessionId()
|
sessionID = GenerateSessionId()
|
||||||
// set the db
|
|
||||||
testutil.SetDatabase(*database, *connStr, *dbSchema)
|
|
||||||
|
|
||||||
// Cleanup the db after tests
|
// Cleanup the db after tests
|
||||||
defer testutil.CleanDatabase()
|
defer testutil.CleanDatabase()
|
||||||
|
|
||||||
@ -100,7 +94,8 @@ func TestAccountCreationSuccessful(t *testing.T) {
|
|||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
groups := driver.FilterGroupsByName(session.Groups, "account_creation_successful")
|
groups := driver.FilterGroupsByName(session.Groups, "account_creation_successful")
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
for _, step := range group.Steps {
|
for i, step := range group.Steps {
|
||||||
|
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||||
@ -142,7 +137,8 @@ func TestAccountRegistrationRejectTerms(t *testing.T) {
|
|||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
groups := driver.FilterGroupsByName(session.Groups, "account_creation_reject_terms")
|
groups := driver.FilterGroupsByName(session.Groups, "account_creation_reject_terms")
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
for _, step := range group.Steps {
|
for i, step := range group.Steps {
|
||||||
|
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||||
@ -177,7 +173,8 @@ func TestMainMenuHelp(t *testing.T) {
|
|||||||
for _, session := range sessions {
|
for _, session := range sessions {
|
||||||
groups := driver.FilterGroupsByName(session.Groups, "main_menu_help")
|
groups := driver.FilterGroupsByName(session.Groups, "main_menu_help")
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
for _, step := range group.Steps {
|
for i, step := range group.Steps {
|
||||||
|
logg.TraceCtxf(ctx, "executing step", "i", i, "step", step)
|
||||||
cont, err := en.Exec(ctx, []byte(step.Input))
|
cont, err := en.Exec(ctx, []byte(step.Input))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err)
|
||||||
|
@ -12,7 +12,7 @@ func (p *Profile) InsertOrShift(index int, value string) {
|
|||||||
for len(p.ProfileItems) < index {
|
for len(p.ProfileItems) < index {
|
||||||
p.ProfileItems = append(p.ProfileItems, "0")
|
p.ProfileItems = append(p.ProfileItems, "0")
|
||||||
}
|
}
|
||||||
p.ProfileItems = append(p.ProfileItems, "0")
|
p.ProfileItems = append(p.ProfileItems, "0")
|
||||||
p.ProfileItems[index] = value
|
p.ProfileItems[index] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
|
//go:build !online
|
||||||
// +build !online
|
// +build !online
|
||||||
|
|
||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
type localEmitter struct {
|
type localEmitter struct {
|
||||||
@ -37,7 +38,7 @@ func (d *localEmitter) emit(ctx context.Context, msg apievent.Msg) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) remote.AccountService {
|
func New(ctx context.Context, storageService storage.StorageService) remote.AccountService {
|
||||||
svc := devremote.NewDevAccountService(ctx, storageService)
|
svc := devremote.NewDevAccountService(ctx, storageService)
|
||||||
svc = svc.WithAutoVoucher(ctx, "FOO", 42)
|
svc = svc.WithAutoVoucher(ctx, "FOO", 42)
|
||||||
eu := event.NewEventsUpdater(svc, storageService)
|
eu := event.NewEventsUpdater(svc, storageService)
|
||||||
|
@ -4,8 +4,8 @@ TXTS = $(wildcard ./*.txt.orig)
|
|||||||
VISE_PATH := ../../go-vise
|
VISE_PATH := ../../go-vise
|
||||||
|
|
||||||
# Rule to build .bin files from .vis files
|
# Rule to build .bin files from .vis files
|
||||||
%.vis:
|
%.vis: buildasm
|
||||||
go run $(VISE_PATH)/dev/asm/main.go -f pp.csv $(basename $@).vis > $(basename $@).bin
|
./vise-asm -f pp.csv $(basename $@).vis > $(basename $@).bin
|
||||||
@echo "Built $(basename $@).bin from $(basename $@).vis"
|
@echo "Built $(basename $@).bin from $(basename $@).vis"
|
||||||
|
|
||||||
# Rule to copy .orig files to .txt
|
# Rule to copy .orig files to .txt
|
||||||
@ -19,5 +19,10 @@ all: $(INPUTS) $(TXTS)
|
|||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -vf *.bin
|
rm -vf *.bin
|
||||||
|
rm -vf ./vise-asm
|
||||||
|
|
||||||
|
buildasm:
|
||||||
|
go build -v -o ./vise-asm $(VISE_PATH)/dev/asm/main.go
|
||||||
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,5 @@
|
|||||||
|
LOAD check_blocked_status 1
|
||||||
|
RELOAD check_blocked_status
|
||||||
CATCH blocked_account flag_account_blocked 1
|
CATCH blocked_account flag_account_blocked 1
|
||||||
CATCH select_language flag_language_set 0
|
CATCH select_language flag_language_set 0
|
||||||
CATCH terms flag_account_created 0
|
CATCH terms flag_account_created 0
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ RELOAD transaction_reset
|
|||||||
CATCH no_voucher flag_no_active_voucher 1
|
CATCH no_voucher flag_no_active_voucher 1
|
||||||
MOUT back 0
|
MOUT back 0
|
||||||
HALT
|
HALT
|
||||||
LOAD validate_recipient 20
|
LOAD validate_recipient 50
|
||||||
RELOAD validate_recipient
|
RELOAD validate_recipient
|
||||||
CATCH invalid_recipient flag_invalid_recipient 1
|
CATCH invalid_recipient flag_invalid_recipient 1
|
||||||
CATCH invite_recipient flag_invalid_recipient_with_invite 1
|
CATCH invite_recipient flag_invalid_recipient_with_invite 1
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user