Compare commits
No commits in common. "master" and "lash/initial-language" have entirely different histories.
master
...
lash/initi
@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
!/args
|
|
||||||
!/cmd/africastalking
|
|
||||||
!/cmd/ssh
|
|
||||||
!/config
|
|
||||||
!/debug
|
|
||||||
!/handlers
|
|
||||||
!/internal
|
|
||||||
!/profile
|
|
||||||
!/services
|
|
||||||
!/ssh
|
|
||||||
!/store
|
|
||||||
!/LICENSE
|
|
||||||
!/README.md
|
|
||||||
!/go.*
|
|
||||||
!/.env.example
|
|
@ -18,6 +18,3 @@ 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
56
.github/workflows/docker.yaml
vendored
@ -1,56 +0,0 @@
|
|||||||
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
50
Dockerfile
@ -1,50 +0,0 @@
|
|||||||
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,14 +19,16 @@ 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,19 @@ import (
|
|||||||
"syscall"
|
"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/lang"
|
||||||
"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/request"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
|
||||||
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
at "git.grassecon.net/grassrootseconomics/visedriver-africastalking/africastalking"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
|
|
||||||
|
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -36,7 +37,8 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
|
var resourceDir string
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var host string
|
var host string
|
||||||
@ -45,11 +47,10 @@ 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,14 +58,16 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
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, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "build", build, "conn", conns, "outputsize", size)
|
logg.Infof("start command", "build", build, "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ln, err := lang.LanguageFromCode(config.Language())
|
ln, err := lang.LanguageFromCode(config.Language())
|
||||||
@ -87,7 +90,7 @@ func main() {
|
|||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(conns)
|
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||||
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)
|
||||||
@ -99,6 +102,7 @@ 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 {
|
||||||
@ -117,8 +121,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService)
|
accountService := &httpremote.HTTPAccountService{}
|
||||||
|
|
||||||
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)
|
||||||
@ -130,6 +133,7 @@ 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)
|
||||||
@ -142,10 +146,7 @@ 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,
|
||||||
}
|
}
|
||||||
shutdownFunc := func() {
|
s.RegisterOnShutdown(sh.Shutdown)
|
||||||
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/args"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"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"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
|
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -44,8 +44,9 @@ func (p *asyncRequestParser) GetInput(r any) ([]byte, error) {
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
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
|
||||||
@ -55,11 +56,8 @@ 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(&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 data directory")
|
flag.StringVar(&connStr, "c", "", "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.Host(), "http host")
|
flag.StringVar(&host, "h", config.Host(), "http host")
|
||||||
@ -68,14 +66,16 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
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, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", conns, "outputsize", size, "sessionId", sessionId)
|
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "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(conns)
|
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||||
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(ctx)
|
defer userdataStore.Close()
|
||||||
|
|
||||||
dbResource, ok := rs.(*resource.DbResource)
|
dbResource, ok := rs.(*resource.DbResource)
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -125,8 +125,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 := &httpremote.HTTPAccountService{}
|
||||||
accountService := services.New(ctx, menuStorageService)
|
|
||||||
|
|
||||||
hl, err := lhs.GetHandler(accountService)
|
hl, err := lhs.GetHandler(accountService)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -139,7 +138,7 @@ func main() {
|
|||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
//defer stateStore.Close(ctx)
|
defer stateStore.Close()
|
||||||
|
|
||||||
rp := &asyncRequestParser{
|
rp := &asyncRequestParser{
|
||||||
sessionId: sessionId,
|
sessionId: sessionId,
|
||||||
@ -161,7 +160,7 @@ func main() {
|
|||||||
case _ = <-cint:
|
case _ = <-cint:
|
||||||
case _ = <-cterm:
|
case _ = <-cterm:
|
||||||
}
|
}
|
||||||
sh.Shutdown(ctx)
|
sh.Shutdown()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for true {
|
for true {
|
||||||
@ -177,7 +176,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(ctx, rqs)
|
rqs, err = sh.Reset(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"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
|
||||||
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
|
httprequest "git.grassecon.net/grassrootseconomics/visedriver/request/http"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/request"
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
|
||||||
|
httpremote "git.grassecon.net/grassrootseconomics/sarafu-api/remote/http"
|
||||||
"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,7 +35,8 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
|
var resourceDir string
|
||||||
var size uint
|
var size uint
|
||||||
var engineDebug bool
|
var engineDebug bool
|
||||||
var host string
|
var host string
|
||||||
@ -44,11 +45,8 @@ func main() {
|
|||||||
var gettextDir string
|
var gettextDir string
|
||||||
var langs args.LangVar
|
var langs args.LangVar
|
||||||
|
|
||||||
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.UserConn, "userdata", "?", "userdata store connection string")
|
flag.StringVar(&connStr, "c", "", "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")
|
||||||
@ -57,14 +55,16 @@ func main() {
|
|||||||
flag.Var(&langs, "language", "add symbol resolution for language")
|
flag.Var(&langs, "language", "add symbol resolution for language")
|
||||||
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, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", conns, "outputsize", size)
|
logg.Infof("start command", "conn", connData, "resourcedir", resourceDir, "outputsize", size)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ func main() {
|
|||||||
cfg.EngineDebug = true
|
cfg.EngineDebug = true
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(conns)
|
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||||
|
|
||||||
rs, err := menuStorageService.GetResource(ctx)
|
rs, err := menuStorageService.GetResource(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -101,6 +101,7 @@ 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 {
|
||||||
@ -115,8 +116,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService)
|
accountService := &httpremote.HTTPAccountService{}
|
||||||
|
|
||||||
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())
|
||||||
@ -128,8 +128,7 @@ 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)
|
|
||||||
|
|
||||||
rp := &httprequest.DefaultRequestParser{}
|
rp := &httprequest.DefaultRequestParser{}
|
||||||
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
bsh := request.NewBaseRequestHandler(cfg, rs, stateStore, userdataStore, rp, hl)
|
||||||
@ -138,10 +137,7 @@ 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,
|
||||||
}
|
}
|
||||||
shutdownFunc := func() {
|
s.RegisterOnShutdown(sh.Shutdown)
|
||||||
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,19 +5,17 @@ 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.grassecon.net/grassrootseconomics/sarafu-vise/args"
|
"git.defalsify.org/vise.git/lang"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/services"
|
|
||||||
"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/handlers"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -29,33 +27,34 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
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(&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(&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()
|
||||||
|
|
||||||
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, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", conns, "outputsize", size)
|
logg.Infof("start command", "conn", connData, "outputsize", size)
|
||||||
|
|
||||||
if len(langs.Langs()) == 0 {
|
if len(langs.Langs()) == 0 {
|
||||||
langs.Set(config.Language())
|
langs.Set(config.Language())
|
||||||
@ -81,12 +80,12 @@ func main() {
|
|||||||
MenuSeparator: menuSeparator,
|
MenuSeparator: menuSeparator,
|
||||||
}
|
}
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(conns)
|
menuStorageService := storage.NewMenuStorageService(connData, resourceDir)
|
||||||
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())
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
accountService := services.New(ctx, menuStorageService)
|
accountService := services.New(ctx, menuStorageService, connData)
|
||||||
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)
|
||||||
@ -136,21 +135,6 @@ 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,31 +31,34 @@ var (
|
|||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
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(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
flag.StringVar(&authConnStr, "authdb", "", "auth connection string")
|
||||||
flag.StringVar(&override.ResourceConn, "resource", "?", "resource connection string")
|
flag.StringVar(&resourceDir, "resourcedir", path.Join("services", "registration"), "resource dir")
|
||||||
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()
|
||||||
|
|
||||||
config.Apply(override)
|
if connStr == "" {
|
||||||
conns, err := config.GetConns()
|
connStr = config.DbConn()
|
||||||
|
}
|
||||||
|
if authConnStr == "" {
|
||||||
|
authConnStr = connStr
|
||||||
|
}
|
||||||
|
connData, err := storage.ToConnData(connStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v", 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)
|
||||||
@ -76,14 +79,14 @@ 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", conns, "authconn", authConnData, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
logg.Infof("start command", "conn", connData, "authconn", authConnData, "resourcedir", resourceDir, "outputsize", size, "keyfile", sshKeyFile, "host", host, "port", port)
|
||||||
|
|
||||||
pfp := path.Join(scriptDir, "pp.csv")
|
pfp := path.Join(scriptDir, "pp.csv")
|
||||||
|
|
||||||
cfg := engine.Config{
|
cfg := engine.Config{
|
||||||
Root: "root",
|
Root: "root",
|
||||||
OutputSize: uint32(size),
|
OutputSize: uint32(size),
|
||||||
FlagCount: uint32(128),
|
FlagCount: uint32(16),
|
||||||
}
|
}
|
||||||
if stateDebug {
|
if stateDebug {
|
||||||
cfg.StateDebug = true
|
cfg.StateDebug = true
|
||||||
@ -99,7 +102,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(ctx)
|
err = authKeyStore.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logg.ErrorCtxf(ctx, "keystore close error", "err", err)
|
logg.ErrorCtxf(ctx, "keystore close error", "err", err)
|
||||||
}
|
}
|
||||||
@ -111,13 +114,14 @@ 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: conns,
|
Conn: connData,
|
||||||
SrvKeyFile: sshKeyFile,
|
ResourceDir: resourceDir,
|
||||||
Host: host,
|
SrvKeyFile: sshKeyFile,
|
||||||
Port: port,
|
Host: host,
|
||||||
|
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(ctx)
|
defer store.Close()
|
||||||
|
|
||||||
err = store.AddFromFile(ctx, sshKeyFile, sessionId)
|
err = store.AddFromFile(ctx, sshKeyFile, sessionId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
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,36 +1,24 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
|
||||||
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
"git.grassecon.net/grassrootseconomics/visedriver/env"
|
||||||
|
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
|
||||||
|
apiconfig "git.grassecon.net/grassrootseconomics/sarafu-api/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
func init() {
|
||||||
GetConns = viseconfig.GetConns
|
env.LoadEnvVariables()
|
||||||
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
|
||||||
@ -42,17 +30,10 @@ func LoadConfig() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchDomains() []string {
|
func DbConn() string {
|
||||||
var ParsedDomains []string
|
return viseconfig.DbConn
|
||||||
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 (
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
visedb "git.defalsify.org/vise.git/db"
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
visedb "git.defalsify.org/vise.git/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,10 +32,18 @@ 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 {
|
||||||
@ -45,19 +53,30 @@ 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,4 +1,3 @@
|
|||||||
//go:build debugdb
|
|
||||||
// +build debugdb
|
// +build debugdb
|
||||||
|
|
||||||
package debug
|
package debug
|
||||||
@ -12,37 +11,34 @@ 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_INCORRECT_PIN_ATTEMPTS] = "incorrect pin attempts"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_SELECTED_LANGUAGE_CODE] = "selected language"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_INITIAL_LANGUAGE_CODE] = "initial language"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_SYMBOLS] = "voucher symbols"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_BALANCES] = "voucher balances"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SENDERS] = "tx senders"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_DECIMALS] = "voucher decimals"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_VOUCHER_ADDRESSES] = "voucher addresses"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_VALUES] = "tx values"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_SENDERS] = "tx senders"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_RECIPIENTS] = "tx recipients"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_HASHES] = "tx hashes"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_VALUES] = "tx values"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DATES] = "tx dates"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_ADDRESSES] = "tx addresses"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_SYMBOLS] = "tx symbols"
|
||||||
dbTypStr[db.DATATYPE_USERDATA+1+storedb.DATA_TX_HASHES] = "tx hashes"
|
dbTypStr[db.DATATYPE_USERDATA + 1 + storedb.DATA_TX_DECIMALS] = "tx decimals"
|
||||||
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,13 +3,14 @@ package debug
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
visedb "git.defalsify.org/vise.git/db"
|
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
visedb "git.defalsify.org/vise.git/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 {
|
||||||
@ -24,7 +25,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)
|
||||||
}
|
}
|
||||||
@ -45,7 +46,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)
|
||||||
}
|
}
|
||||||
@ -55,6 +56,7 @@ 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...)
|
||||||
|
|
||||||
@ -68,7 +70,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)
|
||||||
}
|
}
|
||||||
|
7
devtools/admin/admin_numbers.json
Normal file
7
devtools/admin/admin_numbers.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"admins": [
|
||||||
|
{
|
||||||
|
"phonenumber" : "<replace with any admin number to test with >"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
devtools/admin/commands/seed.go
Normal file
47
devtools/admin/commands/seed.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
logg = logging.NewVanilla().WithDomain("adminstore")
|
||||||
|
)
|
||||||
|
|
||||||
|
type Admin struct {
|
||||||
|
PhoneNumber string `json:"phonenumber"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Admins []Admin `json:"admins"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func Seed(ctx context.Context) error {
|
||||||
|
var config Config
|
||||||
|
adminstore, err := store.NewAdminStore(ctx, "../admin_numbers")
|
||||||
|
store := adminstore.FsStore
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer store.Close()
|
||||||
|
data, err := os.ReadFile("admin_numbers.json")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(data, &config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, admin := range config.Admins {
|
||||||
|
err := store.Put(ctx, []byte(admin.PhoneNumber), []byte("1"))
|
||||||
|
if err != nil {
|
||||||
|
logg.Printf(logging.LVL_DEBUG, "Failed to insert admin number", admin.PhoneNumber)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -2,74 +2,16 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"log"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/devtools/admin/commands"
|
||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/config"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/internal/cmd"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
logg = logging.NewVanilla().WithContextKey("SessionId")
|
|
||||||
scriptDir = path.Join("services", "registration")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
|
||||||
|
|
||||||
override := config.NewOverride()
|
|
||||||
var sessionId string
|
|
||||||
|
|
||||||
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
|
|
||||||
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()
|
|
||||||
|
|
||||||
config.Apply(override)
|
|
||||||
conns, err := config.GetConns()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
err := commands.Seed(ctx)
|
||||||
|
|
||||||
pfp := path.Join(scriptDir, "pp.csv")
|
|
||||||
flagParser, err := application.NewFlagManager(pfp)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "flagparser fail: %v\n", err)
|
log.Fatalf("Failed to initialize a list of admins with error %s", err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
x := cmd.NewCmd(sessionId, flagParser)
|
|
||||||
err = x.Parse(flag.Args())
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "cmd parse fail: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
logg.Infof("start command", "conn", conns, "subcmd", x)
|
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(conns)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "menu storage service error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = x.Exec(ctx, menuStorageService)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "cmd exec error: %v\n", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,18 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/lang"
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
"git.defalsify.org/vise.git/logging"
|
||||||
|
"git.defalsify.org/vise.git/lang"
|
||||||
"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
|
||||||
@ -28,8 +29,8 @@ MOVE language_changed
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
logg = logging.NewVanilla()
|
logg = logging.NewVanilla()
|
||||||
mouts string
|
mouts string
|
||||||
incmps string
|
incmps string
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +63,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)
|
||||||
@ -75,7 +76,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)
|
||||||
@ -92,7 +93,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)
|
||||||
@ -106,7 +107,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,58 +19,55 @@ var (
|
|||||||
scriptDir = path.Join("services", "registration")
|
scriptDir = path.Join("services", "registration")
|
||||||
)
|
)
|
||||||
|
|
||||||
func formatItem(k []byte, v []byte, sessionId string) (string, error) {
|
func formatItem(k []byte, v []byte) (string, error) {
|
||||||
o, err := debug.ToKeyInfo(k, sessionId)
|
o, err := debug.FromKey(k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
s := fmt.Sprintf("%v\t%v\n", o.Label, string(v))
|
s := fmt.Sprintf("%vValue: %v\n\n", o, string(v))
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config.LoadConfig()
|
config.LoadConfig()
|
||||||
|
|
||||||
override := config.NewOverride()
|
var connStr string
|
||||||
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(&override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
|
flag.StringVar(&connStr, "c", ".state", "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.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, "conn specification error: %v\n", err)
|
fmt.Fprintf(os.Stderr, "connstr err: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logg.Infof("start command", "conn", conns)
|
logg.Infof("start command", "conn", connData)
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
menuStorageService := storage.NewMenuStorageService(conns)
|
resourceDir := scriptDir
|
||||||
|
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(""))
|
d, err := store.Dump(ctx, []byte(sessionId))
|
||||||
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)
|
||||||
@ -81,19 +78,15 @@ func main() {
|
|||||||
if k == nil {
|
if k == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if !first {
|
r, err := formatItem(k, v)
|
||||||
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\n", err)
|
fmt.Fprintf(os.Stderr, "format db item error: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Printf(r)
|
fmt.Printf(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = store.Close(ctx)
|
err = store.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, err.Error())
|
fmt.Fprintf(os.Stderr, err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
86
devtools/store/generate/main.go
Normal file
86
devtools/store/generate/main.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
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.20250120121301-10739fb4a8c9
|
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694
|
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250113103030-f0b2056fd87d
|
||||||
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
|
||||||
|
24
go.sum
24
go.sum
@ -1,17 +1,13 @@
|
|||||||
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 h1:w7pj1oh7jXrfajahVYU7m7AfHst4C6jNVzDVoaqJ7e8=
|
||||||
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
git.defalsify.org/vise.git v0.2.3-0.20250115000535-e2d329b3f739/go.mod h1:jyBMe1qTYUz3mmuoC9JQ/TvFeW0vTanCUcPu3H8p4Ck=
|
||||||
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 h1:BenzGx6aDHKDwE23/mWIFD2InYIXyzHroZWV3MF5WUk=
|
||||||
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
git.grassecon.net/grassrootseconomics/common v0.0.0-20250113174703-6afccefd1f05/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
|
||||||
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 h1:FgccQi8vipX6dUt+GRiRDYHMR3UqC+plz73vw7y3fyU=
|
||||||
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250123142805-2181388f5bf1/go.mod h1:gOn89ipaDcDvmQXRMQYKUqcw/sJcwVOPVt2eC6Geip8=
|
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250115072214-bca7c5de969f/go.mod h1:tbA4whUGMUIDgQVdIW0sxWPuuXOvZRSny5zeku5hX4k=
|
||||||
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 h1:bX7klKZpX+ZZu1LKbtOXDAhV/KK0YwExehiIi0jusAM=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250124100946-03d19283f6fa/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
|
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250115003256-c0534ede1b63/go.mod h1:Syw9TZyigPAM7t9FvicOm36iUnidt45f0SxzT2JniQ8=
|
||||||
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 h1:q/NO1rEgK3pia32D/tCq5hXfEuJp84COZRwceFvy/MM=
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
|
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-20250121153115-bfb16bd5a57a h1:jyS1Q8ktEGnH8R5ne/1GN7SyuDPtEGTrGtC8Px3fVJc=
|
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121153115-bfb16bd5a57a/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
|
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694 h1:DjJlBSz0S13acft5XZDWk7ZYnzElym0xLMYEVgyNJ+E=
|
|
||||||
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250129070628-5a539172c694/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
@ -14,11 +14,11 @@ import (
|
|||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
"git.defalsify.org/vise.git/resource"
|
"git.defalsify.org/vise.git/resource"
|
||||||
"git.defalsify.org/vise.git/state"
|
"git.defalsify.org/vise.git/state"
|
||||||
"git.grassecon.net/grassrootseconomics/common/pin"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/models"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/testservice"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/testutil/mocks"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
"git.grassecon.net/grassrootseconomics/common/pin"
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
|
||||||
"github.com/alecthomas/assert/v2"
|
"github.com/alecthomas/assert/v2"
|
||||||
@ -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(ctx) // Ensure the DB is closed after each test
|
db.Close() // Ensure the DB is closed after each test
|
||||||
})
|
})
|
||||||
|
|
||||||
return ctx, store
|
return ctx, store
|
||||||
@ -84,7 +84,7 @@ func TestNewMenuHandlers(t *testing.T) {
|
|||||||
|
|
||||||
// Test case for valid UserDataStore
|
// Test case for valid UserDataStore
|
||||||
t.Run("Valid UserDataStore", func(t *testing.T) {
|
t.Run("Valid UserDataStore", func(t *testing.T) {
|
||||||
handlers, err := NewMenuHandlers(fm, store, &accountService, mockReplaceSeparator)
|
handlers, err := NewMenuHandlers(fm.parser, store, nil, &accountService, mockReplaceSeparator)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("expected no error, got %v", err)
|
t.Fatalf("expected no error, got %v", err)
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ func TestNewMenuHandlers(t *testing.T) {
|
|||||||
|
|
||||||
// Test case for nil UserDataStore
|
// Test case for nil UserDataStore
|
||||||
t.Run("Nil UserDataStore", func(t *testing.T) {
|
t.Run("Nil UserDataStore", func(t *testing.T) {
|
||||||
handlers, err := NewMenuHandlers(fm, nil, &accountService, mockReplaceSeparator)
|
handlers, err := NewMenuHandlers(fm.parser, nil, nil, &accountService, mockReplaceSeparator)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected an error, got none")
|
t.Fatal("expected an error, got none")
|
||||||
}
|
}
|
||||||
@ -132,9 +132,16 @@ func TestInit(t *testing.T) {
|
|||||||
t.Fatal(err.Error())
|
t.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
adminstore, err := store.NewAdminStore(ctx, "admin_numbers")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
st := state.NewState(128)
|
st := state.NewState(128)
|
||||||
ca := cache.NewCache()
|
ca := cache.NewCache()
|
||||||
|
|
||||||
|
flag_admin_privilege, _ := fm.GetFlag("flag_admin_privilege")
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
setup func() (*MenuHandlers, context.Context)
|
setup func() (*MenuHandlers, context.Context)
|
||||||
@ -154,40 +161,49 @@ func TestInit(t *testing.T) {
|
|||||||
setup: func() (*MenuHandlers, context.Context) {
|
setup: func() (*MenuHandlers, context.Context) {
|
||||||
pe := persist.NewPersister(testStore).WithSession(sessionId).WithContent(st, ca)
|
pe := persist.NewPersister(testStore).WithSession(sessionId).WithContent(st, ca)
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
|
adminstore: adminstore,
|
||||||
pe: pe,
|
pe: pe,
|
||||||
}
|
}
|
||||||
return h, context.WithValue(ctx, "SessionId", sessionId)
|
return h, context.WithValue(ctx, "SessionId", sessionId)
|
||||||
},
|
},
|
||||||
input: []byte("1"),
|
input: []byte("1"),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{
|
||||||
|
FlagReset: []uint32{flag_admin_privilege},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Non-admin session initialization",
|
name: "Non-admin session initialization",
|
||||||
setup: func() (*MenuHandlers, context.Context) {
|
setup: func() (*MenuHandlers, context.Context) {
|
||||||
pe := persist.NewPersister(testStore).WithSession("0712345678").WithContent(st, ca)
|
pe := persist.NewPersister(testStore).WithSession("0712345678").WithContent(st, ca)
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
|
adminstore: adminstore,
|
||||||
pe: pe,
|
pe: pe,
|
||||||
}
|
}
|
||||||
return h, context.WithValue(context.Background(), "SessionId", "0712345678")
|
return h, context.WithValue(context.Background(), "SessionId", "0712345678")
|
||||||
},
|
},
|
||||||
input: []byte("1"),
|
input: []byte("1"),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{
|
||||||
|
FlagReset: []uint32{flag_admin_privilege},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Move to top node on empty input",
|
name: "Move to top node on empty input",
|
||||||
setup: func() (*MenuHandlers, context.Context) {
|
setup: func() (*MenuHandlers, context.Context) {
|
||||||
pe := persist.NewPersister(testStore).WithSession(sessionId).WithContent(st, ca)
|
pe := persist.NewPersister(testStore).WithSession(sessionId).WithContent(st, ca)
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
|
adminstore: adminstore,
|
||||||
pe: pe,
|
pe: pe,
|
||||||
}
|
}
|
||||||
st.Code = []byte("some pending bytecode")
|
st.Code = []byte("some pending bytecode")
|
||||||
return h, context.WithValue(ctx, "SessionId", sessionId)
|
return h, context.WithValue(ctx, "SessionId", sessionId)
|
||||||
},
|
},
|
||||||
input: []byte(""),
|
input: []byte(""),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{
|
||||||
|
FlagReset: []uint32{flag_admin_privilege},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +256,7 @@ func TestCreateAccount(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
mockAccountService.On("CreateAccount").Return(tt.serverResponse, nil)
|
mockAccountService.On("CreateAccount").Return(tt.serverResponse, nil)
|
||||||
@ -304,7 +320,7 @@ func TestSaveFirstname(t *testing.T) {
|
|||||||
// Create the MenuHandlers instance with the mock store
|
// Create the MenuHandlers instance with the mock store
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +365,7 @@ func TestSaveFamilyname(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
@ -392,7 +408,7 @@ func TestSaveYoB(t *testing.T) {
|
|||||||
// Create the MenuHandlers instance with the mock store
|
// Create the MenuHandlers instance with the mock store
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +452,7 @@ func TestSaveLocation(t *testing.T) {
|
|||||||
// Create the MenuHandlers instance with the mock store
|
// Create the MenuHandlers instance with the mock store
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +496,7 @@ func TestSaveOfferings(t *testing.T) {
|
|||||||
// Create the MenuHandlers instance with the mock store
|
// Create the MenuHandlers instance with the mock store
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +564,7 @@ func TestSaveGender(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedResult := resource.Result{}
|
expectedResult := resource.Result{}
|
||||||
@ -579,11 +595,11 @@ func TestSaveTemporaryPin(t *testing.T) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_incorrect_pin, _ := fm.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := fm.parser.GetFlag("flag_incorrect_pin")
|
||||||
|
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,7 +812,7 @@ func TestSetLanguage(t *testing.T) {
|
|||||||
|
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
@ -830,7 +846,7 @@ func TestResetAllowUpdate(t *testing.T) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_allow_update, _ := fm.GetFlag("flag_allow_update")
|
flag_allow_update, _ := fm.parser.GetFlag("flag_allow_update")
|
||||||
|
|
||||||
// Define test cases
|
// Define test cases
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -851,7 +867,7 @@ func TestResetAllowUpdate(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
@ -872,7 +888,7 @@ func TestResetAccountAuthorized(t *testing.T) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_account_authorized, _ := fm.GetFlag("flag_account_authorized")
|
flag_account_authorized, _ := fm.parser.GetFlag("flag_account_authorized")
|
||||||
|
|
||||||
// Define test cases
|
// Define test cases
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -893,7 +909,7 @@ func TestResetAccountAuthorized(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
@ -917,8 +933,8 @@ func TestIncorrectPinReset(t *testing.T) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_incorrect_pin, _ := fm.GetFlag("flag_incorrect_pin")
|
flag_incorrect_pin, _ := fm.parser.GetFlag("flag_incorrect_pin")
|
||||||
flag_account_blocked, _ := fm.GetFlag("flag_account_blocked")
|
flag_account_blocked, _ := fm.parser.GetFlag("flag_account_blocked")
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
|
|
||||||
@ -976,7 +992,7 @@ func TestIncorrectPinReset(t *testing.T) {
|
|||||||
|
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -998,7 +1014,7 @@ func TestResetIncorrectYob(t *testing.T) {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_incorrect_date_format, _ := fm.GetFlag("flag_incorrect_date_format")
|
flag_incorrect_date_format, _ := fm.parser.GetFlag("flag_incorrect_date_format")
|
||||||
|
|
||||||
// Define test cases
|
// Define test cases
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -1019,7 +1035,7 @@ func TestResetIncorrectYob(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// Create the MenuHandlers instance with the mock flag manager
|
// Create the MenuHandlers instance with the mock flag manager
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the method
|
// Call the method
|
||||||
@ -1057,7 +1073,7 @@ func TestAuthorize(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1125,12 +1141,12 @@ func TestVerifyYob(t *testing.T) {
|
|||||||
// Create required mocks
|
// Create required mocks
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
mockState := state.NewState(16)
|
mockState := state.NewState(16)
|
||||||
flag_incorrect_date_format, _ := fm.GetFlag("flag_incorrect_date_format")
|
flag_incorrect_date_format, _ := fm.parser.GetFlag("flag_incorrect_date_format")
|
||||||
ctx := context.WithValue(context.Background(), "SessionId", sessionId)
|
ctx := context.WithValue(context.Background(), "SessionId", sessionId)
|
||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1190,14 +1206,14 @@ func TestVerifyCreatePin(t *testing.T) {
|
|||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
mockState := state.NewState(16)
|
mockState := state.NewState(16)
|
||||||
|
|
||||||
flag_valid_pin, _ := fm.GetFlag("flag_valid_pin")
|
flag_valid_pin, _ := fm.parser.GetFlag("flag_valid_pin")
|
||||||
flag_pin_mismatch, _ := fm.GetFlag("flag_pin_mismatch")
|
flag_pin_mismatch, _ := fm.parser.GetFlag("flag_pin_mismatch")
|
||||||
flag_pin_set, _ := fm.GetFlag("flag_pin_set")
|
flag_pin_set, _ := fm.parser.GetFlag("flag_pin_set")
|
||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
st: mockState,
|
st: mockState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,20 +1239,13 @@ 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))
|
||||||
|
|
||||||
@ -1298,7 +1307,7 @@ func TestCheckAccountStatus(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(tt.publicKey))
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(tt.publicKey))
|
||||||
@ -1338,7 +1347,7 @@ func TestTransactionReset(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -1378,14 +1387,14 @@ func TestResetTransactionAmount(t *testing.T) {
|
|||||||
t.Logf(err.Error())
|
t.Logf(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
flag_invalid_amount, _ := fm.GetFlag("flag_invalid_amount")
|
flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||||
|
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -1422,14 +1431,14 @@ func TestInitiateTransaction(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf(err.Error())
|
t.Logf(err.Error())
|
||||||
}
|
}
|
||||||
account_authorized_flag, _ := fm.GetFlag("flag_account_authorized")
|
account_authorized_flag, _ := fm.parser.GetFlag("flag_account_authorized")
|
||||||
|
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -1515,7 +1524,7 @@ func TestQuit(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Logf(err.Error())
|
t.Logf(err.Error())
|
||||||
}
|
}
|
||||||
flag_account_authorized, _ := fm.GetFlag("flag_account_authorized")
|
flag_account_authorized, _ := fm.parser.GetFlag("flag_account_authorized")
|
||||||
|
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
|
|
||||||
@ -1525,7 +1534,7 @@ func TestQuit(t *testing.T) {
|
|||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -1568,14 +1577,14 @@ func TestValidateAmount(t *testing.T) {
|
|||||||
ctx, store := InitializeTestStore(t)
|
ctx, store := InitializeTestStore(t)
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
|
|
||||||
flag_invalid_amount, _ := fm.GetFlag("flag_invalid_amount")
|
flag_invalid_amount, _ := fm.parser.GetFlag("flag_invalid_amount")
|
||||||
|
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
@ -1642,8 +1651,8 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
ctx, store := InitializeTestStore(t)
|
ctx, store := InitializeTestStore(t)
|
||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
|
|
||||||
flag_invalid_recipient, _ := fm.GetFlag("flag_invalid_recipient")
|
flag_invalid_recipient, _ := fm.parser.GetFlag("flag_invalid_recipient")
|
||||||
flag_invalid_recipient_with_invite, _ := fm.GetFlag("flag_invalid_recipient_with_invite")
|
flag_invalid_recipient_with_invite, _ := fm.parser.GetFlag("flag_invalid_recipient_with_invite")
|
||||||
|
|
||||||
// Define test cases
|
// Define test cases
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -1679,7 +1688,7 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Test with alias recepient",
|
name: "Test with alias recepient",
|
||||||
input: []byte("alias123.sarafu.local"),
|
input: []byte("alias123"),
|
||||||
expectedResult: resource.Result{},
|
expectedResult: resource.Result{},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -1695,7 +1704,7 @@ func TestValidateRecipient(t *testing.T) {
|
|||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
// Create the MenuHandlers instance
|
// Create the MenuHandlers instance
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
}
|
}
|
||||||
@ -1797,37 +1806,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, storedb.DATA_ACCOUNT_ALIAS},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
||||||
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\nYour alias: %s\n",
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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, storedb.DATA_ACCOUNT_ALIAS},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
||||||
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\nLakabu yako: %s\n",
|
"Jina: %s\nJinsia: %s\nUmri: %s\nEneo: %s\nUnauza: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
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, storedb.DATA_ACCOUNT_ALIAS},
|
keys: []storedb.DataTyp{storedb.DATA_FAMILY_NAME, storedb.DATA_FIRST_NAME, storedb.DATA_GENDER, storedb.DATA_OFFERINGS, storedb.DATA_LOCATION, storedb.DATA_YOB},
|
||||||
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976", "DoeJohn"},
|
profileInfo: []string{"Doee", "John", "Male", "Bananas", "Kilifi", "1976"},
|
||||||
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\nYour alias: %s\n",
|
"Name: %s\nGender: %s\nAge: %s\nLocation: %s\nYou provide: %s\n",
|
||||||
"John Doee", "Male", "49", "Kilifi", "Bananas", "DoeJohn",
|
"John Doee", "Male", "49", "Kilifi", "Bananas",
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1858,10 +1867,10 @@ func TestVerifyNewPin(t *testing.T) {
|
|||||||
|
|
||||||
fm, _ := NewFlagManager(flagsPath)
|
fm, _ := NewFlagManager(flagsPath)
|
||||||
|
|
||||||
flag_valid_pin, _ := fm.GetFlag("flag_valid_pin")
|
flag_valid_pin, _ := fm.parser.GetFlag("flag_valid_pin")
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
}
|
}
|
||||||
ctx := context.WithValue(context.Background(), "SessionId", sessionId)
|
ctx := context.WithValue(context.Background(), "SessionId", sessionId)
|
||||||
@ -1904,24 +1913,24 @@ func TestConfirmPin(t *testing.T) {
|
|||||||
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
ctx = context.WithValue(ctx, "SessionId", sessionId)
|
||||||
|
|
||||||
fm, _ := NewFlagManager(flagsPath)
|
fm, _ := NewFlagManager(flagsPath)
|
||||||
flag_pin_mismatch, _ := fm.GetFlag("flag_pin_mismatch")
|
flag_pin_mismatch, _ := fm.parser.GetFlag("flag_pin_mismatch")
|
||||||
mockAccountService := new(mocks.MockAccountService)
|
mockAccountService := new(mocks.MockAccountService)
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
}
|
}
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input []byte
|
input []byte
|
||||||
temporarypin string
|
temporarypin []byte
|
||||||
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: "1234",
|
temporarypin: []byte("1234"),
|
||||||
expectedResult: resource.Result{
|
expectedResult: resource.Result{
|
||||||
FlagReset: []uint32{flag_pin_mismatch},
|
FlagReset: []uint32{flag_pin_mismatch},
|
||||||
},
|
},
|
||||||
@ -1929,21 +1938,14 @@ 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(hashedPIN))
|
err := store.WriteEntry(ctx, sessionId, storedb.DATA_TEMPORARY_VALUE, []byte(tt.temporarypin))
|
||||||
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.input)
|
res, _ := h.ConfirmPinChange(ctx, "confirm_pin_change", tt.temporarypin)
|
||||||
|
|
||||||
//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")
|
||||||
@ -2045,7 +2047,7 @@ func TestSetDefaultVoucher(t *testing.T) {
|
|||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := store.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(publicKey))
|
err := store.WriteEntry(ctx, sessionId, storedb.DATA_PUBLIC_KEY, []byte(publicKey))
|
||||||
@ -2153,7 +2155,7 @@ func TestViewVoucher(t *testing.T) {
|
|||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
prefixDb: spdb,
|
prefixDb: spdb,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2226,7 +2228,7 @@ func TestGetVoucherDetails(t *testing.T) {
|
|||||||
|
|
||||||
h := &MenuHandlers{
|
h := &MenuHandlers{
|
||||||
userdataStore: store,
|
userdataStore: store,
|
||||||
flagManager: fm,
|
flagManager: fm.parser,
|
||||||
accountService: mockAccountService,
|
accountService: mockAccountService,
|
||||||
}
|
}
|
||||||
err = store.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_ADDRESS, []byte(tokA_AAddress))
|
err = store.WriteEntry(ctx, sessionId, storedb.DATA_ACTIVE_ADDRESS, []byte(tokA_AAddress))
|
||||||
|
@ -35,6 +35,13 @@ 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/logging"
|
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
"git.defalsify.org/vise.git/logging"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
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/common/identity"
|
|
||||||
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
storedb "git.grassecon.net/grassrootseconomics/sarafu-vise/store/db"
|
||||||
|
"git.grassecon.net/grassrootseconomics/common/identity"
|
||||||
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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,6 +47,7 @@ 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)
|
||||||
@ -58,6 +59,7 @@ 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.
|
||||||
@ -187,7 +189,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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.defalsify.org/vise.git/asm"
|
||||||
"git.defalsify.org/vise.git/db"
|
"git.defalsify.org/vise.git/db"
|
||||||
"git.defalsify.org/vise.git/engine"
|
"git.defalsify.org/vise.git/engine"
|
||||||
"git.defalsify.org/vise.git/persist"
|
"git.defalsify.org/vise.git/persist"
|
||||||
@ -11,35 +12,47 @@ import (
|
|||||||
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
type HandlerService interface {
|
type HandlerService interface {
|
||||||
GetHandler() (*application.MenuHandlers, error)
|
GetHandler() (*application.MenuHandlers, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getParser(fp string, debug bool) (*asm.FlagParser, error) {
|
||||||
|
flagParser := asm.NewFlagParser().WithDebug()
|
||||||
|
_, err := flagParser.Load(fp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return flagParser, nil
|
||||||
|
}
|
||||||
|
|
||||||
type LocalHandlerService struct {
|
type LocalHandlerService struct {
|
||||||
Parser *application.FlagManager
|
Parser *asm.FlagParser
|
||||||
DbRs *resource.DbResource
|
DbRs *resource.DbResource
|
||||||
Pe *persist.Persister
|
Pe *persist.Persister
|
||||||
UserdataStore *db.Db
|
UserdataStore *db.Db
|
||||||
|
AdminStore *store.AdminStore
|
||||||
Cfg engine.Config
|
Cfg engine.Config
|
||||||
Rs resource.Resource
|
Rs resource.Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocalHandlerService(ctx context.Context, fp string, debug bool, dbResource *resource.DbResource, cfg engine.Config, rs resource.Resource) (*LocalHandlerService, error) {
|
func NewLocalHandlerService(ctx context.Context, fp string, debug bool, dbResource *resource.DbResource, cfg engine.Config, rs resource.Resource) (*LocalHandlerService, error) {
|
||||||
parser, err := application.NewFlagManager(fp)
|
parser, err := getParser(fp, debug)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if debug {
|
adminstore, err := store.NewAdminStore(ctx, "admin_numbers")
|
||||||
parser.SetDebug()
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &LocalHandlerService{
|
return &LocalHandlerService{
|
||||||
Parser: parser,
|
Parser: parser,
|
||||||
DbRs: dbResource,
|
DbRs: dbResource,
|
||||||
Cfg: cfg,
|
AdminStore: adminstore,
|
||||||
Rs: rs,
|
Cfg: cfg,
|
||||||
|
Rs: rs,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +69,12 @@ func (ls *LocalHandlerService) GetHandler(accountService remote.AccountService)
|
|||||||
return strings.ReplaceAll(input, ":", ls.Cfg.MenuSeparator)
|
return strings.ReplaceAll(input, ":", ls.Cfg.MenuSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
appHandlers, err := application.NewMenuHandlers(ls.Parser, *ls.UserdataStore, accountService, replaceSeparatorFunc)
|
appHandlers, err := application.NewMenuHandlers(ls.Parser, *ls.UserdataStore, ls.AdminStore, accountService, replaceSeparatorFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
//appHandlers = appHandlers.WithPersister(ls.Pe)
|
//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)
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/application"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
logg = logging.NewVanilla().WithDomain("cmd").WithContextKey("SessionId")
|
|
||||||
)
|
|
||||||
|
|
||||||
type Cmd struct {
|
|
||||||
sessionId string
|
|
||||||
conn storage.ConnData
|
|
||||||
flagParser *application.FlagManager
|
|
||||||
cmd int
|
|
||||||
enable bool
|
|
||||||
exec func(ctx context.Context, ss storage.StorageService) error
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCmd(sessionId string, flagParser *application.FlagManager) *Cmd {
|
|
||||||
return &Cmd{
|
|
||||||
sessionId: sessionId,
|
|
||||||
flagParser: flagParser,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cmd) Exec(ctx context.Context, ss storage.StorageService) error {
|
|
||||||
return c.exec(ctx, ss)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cmd) execAdmin(ctx context.Context, ss storage.StorageService) error {
|
|
||||||
pe, err := ss.GetPersister(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
err = pe.Load(c.sessionId)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
err := pe.Save(c.sessionId)
|
|
||||||
if err != nil {
|
|
||||||
logg.ErrorCtxf(ctx, "failed persister save: %v", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
st := pe.GetState()
|
|
||||||
flag, err := c.flagParser.GetFlag("flag_admin_privilege")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c.enable {
|
|
||||||
logg.InfoCtxf(ctx, "setting admin flag", "flag", flag)
|
|
||||||
st.SetFlag(flag)
|
|
||||||
} else {
|
|
||||||
st.ResetFlag(flag)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cmd) parseCmdAdmin(cmd string, param string, more []string) (bool, error) {
|
|
||||||
if cmd == "admin" {
|
|
||||||
if param == "1" {
|
|
||||||
c.enable = true
|
|
||||||
} else if param != "0" {
|
|
||||||
return false, fmt.Errorf("invalid parameter: %v", param)
|
|
||||||
}
|
|
||||||
c.exec = c.execAdmin
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Cmd) Parse(args []string) error {
|
|
||||||
if len(args) < 2 {
|
|
||||||
return fmt.Errorf("Wrong number of arguments: %v", args)
|
|
||||||
}
|
|
||||||
cmd := args[0]
|
|
||||||
param := args[1]
|
|
||||||
args = args[2:]
|
|
||||||
|
|
||||||
r, err := c.parseCmdAdmin(cmd, param, args)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if r {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
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\nYour alias: \n\n0:Back\n9:Quit"
|
"expectedContent": "My profile:\nName: foo bar\nGender: male\nAge: 80\nLocation: Kilifi\nYou provide: Bananas\n\n0:Back\n9:Quit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": "0",
|
"input": "0",
|
||||||
|
@ -9,14 +9,12 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.defalsify.org/vise.git/logging"
|
|
||||||
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
|
||||||
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
|
||||||
"github.com/gofrs/uuid"
|
"github.com/gofrs/uuid"
|
||||||
|
"git.grassecon.net/grassrootseconomics/visedriver/testutil/driver"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/testutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
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)
|
||||||
@ -24,6 +22,9 @@ 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))
|
||||||
@ -79,7 +80,12 @@ 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()
|
||||||
|
|
||||||
@ -94,8 +100,7 @@ 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 i, step := range group.Steps {
|
for _, 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)
|
||||||
@ -137,8 +142,7 @@ 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 i, step := range group.Steps {
|
for _, 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)
|
||||||
@ -173,8 +177,7 @@ 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 i, step := range group.Steps {
|
for _, 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,17 +1,16 @@
|
|||||||
//go:build !online
|
|
||||||
// +build !online
|
// +build !online
|
||||||
|
|
||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"context"
|
||||||
|
|
||||||
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
|
||||||
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/visedriver/storage"
|
"git.grassecon.net/grassrootseconomics/visedriver/storage"
|
||||||
|
devremote "git.grassecon.net/grassrootseconomics/sarafu-api/dev"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-api/remote"
|
||||||
|
apievent "git.grassecon.net/grassrootseconomics/sarafu-api/event"
|
||||||
|
"git.grassecon.net/grassrootseconomics/sarafu-vise/handlers/event"
|
||||||
)
|
)
|
||||||
|
|
||||||
type localEmitter struct {
|
type localEmitter struct {
|
||||||
@ -38,7 +37,7 @@ func (d *localEmitter) emit(ctx context.Context, msg apievent.Msg) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(ctx context.Context, storageService storage.StorageService) remote.AccountService {
|
func New(ctx context.Context, storageService storage.StorageService, conn storage.ConnData) 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: buildasm
|
%.vis:
|
||||||
./vise-asm -f pp.csv $(basename $@).vis > $(basename $@).bin
|
go run $(VISE_PATH)/dev/asm/main.go -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,10 +19,5 @@ 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
|
||||||
|
BIN
services/registration/_catch.bin
Normal file
BIN
services/registration/_catch.bin
Normal file
Binary file not shown.
BIN
services/registration/account_creation.bin
Normal file
BIN
services/registration/account_creation.bin
Normal file
Binary file not shown.
BIN
services/registration/account_creation_failed.bin
Normal file
BIN
services/registration/account_creation_failed.bin
Normal file
Binary file not shown.
@ -1 +1 @@
|
|||||||
Your account is still being created. For more help, please call: 0757628885
|
Your account is still being created.
|
BIN
services/registration/account_pending.bin
Normal file
BIN
services/registration/account_pending.bin
Normal file
Binary file not shown.
@ -1 +1 @@
|
|||||||
Akaunti yako bado inatengenezwa. Kwa usaidizi zaidi, piga: 0757628885
|
Akaunti yako bado inatengenezwa
|
BIN
services/registration/address.bin
Normal file
BIN
services/registration/address.bin
Normal file
Binary file not shown.
BIN
services/registration/amount.bin
Normal file
BIN
services/registration/amount.bin
Normal file
Binary file not shown.
BIN
services/registration/api_failure.bin
Normal file
BIN
services/registration/api_failure.bin
Normal file
Binary file not shown.
BIN
services/registration/balances.bin
Normal file
BIN
services/registration/balances.bin
Normal file
Binary file not shown.
BIN
services/registration/blocked_account.bin
Normal file
BIN
services/registration/blocked_account.bin
Normal file
Binary file not shown.
BIN
services/registration/change_language.bin
Normal file
BIN
services/registration/change_language.bin
Normal file
Binary file not shown.
BIN
services/registration/check_statement.bin
Normal file
BIN
services/registration/check_statement.bin
Normal file
Binary file not shown.
BIN
services/registration/community_balance.bin
Normal file
BIN
services/registration/community_balance.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_create_pin.bin
Normal file
BIN
services/registration/confirm_create_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_others_new_pin.bin
Normal file
BIN
services/registration/confirm_others_new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/confirm_pin_change.bin
Normal file
BIN
services/registration/confirm_pin_change.bin
Normal file
Binary file not shown.
BIN
services/registration/create_pin.bin
Normal file
BIN
services/registration/create_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/create_pin_mismatch.bin
Normal file
BIN
services/registration/create_pin_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/display_profile_info.bin
Normal file
BIN
services/registration/display_profile_info.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_family_name.bin
Normal file
BIN
services/registration/edit_family_name.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_first_name.bin
Normal file
BIN
services/registration/edit_first_name.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_location.bin
Normal file
BIN
services/registration/edit_location.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_offerings.bin
Normal file
BIN
services/registration/edit_offerings.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_profile.bin
Normal file
BIN
services/registration/edit_profile.bin
Normal file
Binary file not shown.
BIN
services/registration/edit_yob.bin
Normal file
BIN
services/registration/edit_yob.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_other_number.bin
Normal file
BIN
services/registration/enter_other_number.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_others_new_pin.bin
Normal file
BIN
services/registration/enter_others_new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/enter_pin.bin
Normal file
BIN
services/registration/enter_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/help.bin
Normal file
BIN
services/registration/help.bin
Normal file
Binary file not shown.
BIN
services/registration/incorrect_date_format.bin
Normal file
BIN
services/registration/incorrect_date_format.bin
Normal file
Binary file not shown.
BIN
services/registration/incorrect_pin.bin
Normal file
BIN
services/registration/incorrect_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_amount.bin
Normal file
BIN
services/registration/invalid_amount.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_others_pin.bin
Normal file
BIN
services/registration/invalid_others_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_pin.bin
Normal file
BIN
services/registration/invalid_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/invalid_recipient.bin
Normal file
BIN
services/registration/invalid_recipient.bin
Normal file
Binary file not shown.
BIN
services/registration/invite_recipient.bin
Normal file
BIN
services/registration/invite_recipient.bin
Normal file
Binary file not shown.
BIN
services/registration/invite_result.bin
Normal file
BIN
services/registration/invite_result.bin
Normal file
Binary file not shown.
BIN
services/registration/language_changed.bin
Normal file
BIN
services/registration/language_changed.bin
Normal file
Binary file not shown.
0
services/registration/list_offering.bin
Normal file
0
services/registration/list_offering.bin
Normal file
BIN
services/registration/main.bin
Normal file
BIN
services/registration/main.bin
Normal file
Binary file not shown.
BIN
services/registration/my_account.bin
Normal file
BIN
services/registration/my_account.bin
Normal file
Binary file not shown.
BIN
services/registration/my_balance.bin
Normal file
BIN
services/registration/my_balance.bin
Normal file
Binary file not shown.
BIN
services/registration/my_vouchers.bin
Normal file
BIN
services/registration/my_vouchers.bin
Normal file
Binary file not shown.
BIN
services/registration/new_pin.bin
Normal file
BIN
services/registration/new_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/no_admin_privilege.bin
Normal file
BIN
services/registration/no_admin_privilege.bin
Normal file
Binary file not shown.
BIN
services/registration/no_transfers.bin
Normal file
BIN
services/registration/no_transfers.bin
Normal file
Binary file not shown.
BIN
services/registration/no_voucher.bin
Normal file
BIN
services/registration/no_voucher.bin
Normal file
Binary file not shown.
BIN
services/registration/old_pin.bin
Normal file
BIN
services/registration/old_pin.bin
Normal file
Binary file not shown.
BIN
services/registration/others_pin_mismatch.bin
Normal file
BIN
services/registration/others_pin_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_entry.bin
Normal file
BIN
services/registration/pin_entry.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_management.bin
Normal file
BIN
services/registration/pin_management.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_mismatch.bin
Normal file
BIN
services/registration/pin_reset_mismatch.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_result.bin
Normal file
BIN
services/registration/pin_reset_result.bin
Normal file
Binary file not shown.
BIN
services/registration/pin_reset_success.bin
Normal file
BIN
services/registration/pin_reset_success.bin
Normal file
Binary file not shown.
BIN
services/registration/profile_update_success.bin
Normal file
BIN
services/registration/profile_update_success.bin
Normal file
Binary file not shown.
BIN
services/registration/quit.bin
Normal file
BIN
services/registration/quit.bin
Normal file
Binary file not shown.
BIN
services/registration/root.bin
Normal file
BIN
services/registration/root.bin
Normal file
Binary file not shown.
@ -1,11 +1,9 @@
|
|||||||
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
|
||||||
LOAD check_account_status 0
|
LOAD check_account_status 0
|
||||||
RELOAD check_account_status
|
RELOAD check_account_status
|
||||||
CATCH api_failure flag_api_call_error 1
|
CATCH api_failure flag_api_call_error 1
|
||||||
CATCH account_pending flag_account_pending 1
|
CATCH account_pending flag_account_pending 1
|
||||||
CATCH create_pin flag_pin_set 0
|
CATCH create_pin flag_pin_set 0
|
||||||
CATCH main flag_account_success 1
|
CATCH main flag_account_success 1
|
||||||
|
BIN
services/registration/select_gender.bin
Normal file
BIN
services/registration/select_gender.bin
Normal file
Binary file not shown.
BIN
services/registration/select_language.bin
Normal file
BIN
services/registration/select_language.bin
Normal file
Binary file not shown.
BIN
services/registration/select_voucher.bin
Normal file
BIN
services/registration/select_voucher.bin
Normal file
Binary file not shown.
BIN
services/registration/send.bin
Normal file
BIN
services/registration/send.bin
Normal file
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 50
|
LOAD validate_recipient 20
|
||||||
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
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user