Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
422b235
Resolve conflict
yimyitbarek Mar 18, 2026
8019260
make issuer issue mdoc verifiable credentials
yimyitbarek Mar 19, 2026
36d5fac
Add Dockerfile with separate build stages for ZK and verifier
yimyitbarek Mar 9, 2026
37998b8
Load ZK circuits
yimyitbarek Mar 9, 2026
c7967a7
Implement ZK verification
yimyitbarek Mar 9, 2026
c5eb177
Add test
yimyitbarek Mar 10, 2026
95e2be9
Use ZKP in instead of generic names
yimyitbarek Mar 10, 2026
4041f67
use config file instead of flag to read certs
yimyitbarek Mar 10, 2026
42779fc
vendor longfellow-zk
yimyitbarek Mar 10, 2026
abb019d
resolve verifier build and vendoring issues
yimyitbarek Mar 10, 2026
5651f6c
update docker image name
yimyitbarek Mar 11, 2026
b614344
conditionally include ZK support based on build args
yimyitbarek Mar 11, 2026
75da835
sync dependencies and vendor modules before running tests
yimyitbarek Mar 11, 2026
74e68c7
fix go dependency sync by mirroring docker build environment
yimyitbarek Mar 13, 2026
4e57281
remove validate requirement
yimyitbarek Mar 13, 2026
e2a218c
make zk setup conditional
yimyitbarek Mar 13, 2026
74e7645
simplify test workflow by skipping zk requirements
yimyitbarek Mar 13, 2026
898d8a0
simplify test workflow by skipping zk requirements
yimyitbarek Mar 13, 2026
01e67fc
simplify test workflow by skipping zk requirements
yimyitbarek Mar 13, 2026
f1d21de
simplify test workflow by skipping zk requirements
yimyitbarek Mar 13, 2026
10c9c6e
simplify test workflow by skipping zk requirements
yimyitbarek Mar 13, 2026
3a94fa2
Use specific commit of the longfellow dependency
yimyitbarek Mar 13, 2026
36bb5e4
configure http server timeouts
yimyitbarek Mar 13, 2026
ccbfbc2
Refactor verification handler
yimyitbarek Mar 19, 2026
ac05e7c
Add comment to Makefile
yimyitbarek Mar 21, 2026
94078d9
Add cache-dependency-path for dependency caching
yimyitbarek Mar 21, 2026
f0cd17e
Set audit log to false
yimyitbarek Mar 21, 2026
d7bf66a
Merge branch 'main' into feature/longfellow-zk/verification
yimyitbarek Mar 21, 2026
972a024
Add a test for makemdoc
yimyitbarek Mar 21, 2026
4062431
Remove redundant vendor copy
yimyitbarek Mar 22, 2026
3c4cac1
Update sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
6880adc
Update sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
cb2b8a0
Update rules of sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
aedc326
Update rules of sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
a8c5c94
Update rules of sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
82ec860
Update rules of sonar config to ignore docker COPY and root user
yimyitbarek Mar 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,16 @@ jobs:
go-version-file: go.mod
cache-dependency-path: "**/*.sum"

- name: Clone Missing Dependency
run: |
git clone https://github.com/google/longfellow-zk.git /tmp/longfellow-zk
cd /tmp/longfellow-zk
git checkout 66fab34ac83bdb669be35ca380e16191468e96d4

- name: Sync dependencies
run: |
go mod tidy
go mod vendor
Comment on lines +23 to +26

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running go mod tidy + go mod vendor inside CI mutates go.mod/go.sum/vendor during the workflow, which makes the build non-deterministic and can mask the fact that the repo isn't kept tidy/vendor'd in git. It also works around the /tmp-based replace rather than fixing it. Prefer committing the correct module dependency (or removing the local replace) and have CI verify go mod tidy/go mod vendor are already clean (or run tests with -mod=vendor without rewriting files).

Suggested change
- name: Sync dependencies
run: |
go mod tidy
go mod vendor
- name: Verify dependencies are tidy and vendored
run: |
go mod tidy
go mod vendor
git diff --exit-code -- go.mod go.sum vendor/

Copilot uses AI. Check for mistakes.

- name: Run tests
run: make test
44 changes: 42 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ RESERVED_TAGS := latest testing demo dev
# PKCS#11 requires CGO for hardware security module support.
PKCS11_TAG := pkcs11

VC20_TAG := vc20
ALL_TAGS := $(SAML_TAG),$(OIDCRP_TAG)
ZK_TAG := zk

# Service Build Configuration (service -> static/dynamic, tags)
# Format: service_name:cgo_mode:build_tags
BUILD_CONFIGS := \
verifier:static: \
verifier:dynamic:${ZK_TAG} \

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the default verifier build to dynamic + zk tag. That means make build / standard CI/builds will now require the Longfellow native libraries + CGO toolchain, breaking existing environments where ZK is not needed. ZK should be an opt-in build (separate build target/config) rather than the default for the verifier service.

Suggested change
verifier:dynamic:${ZK_TAG} \
verifier:dynamic: \

Copilot uses AI. Check for mistakes.
registry:static: \
mockas:static: \
apigw:static: \
Expand Down Expand Up @@ -189,6 +193,11 @@ test-pkcs11: ## Test with PKCS#11 build tag
$(info Testing with PKCS#11 build tag)
go test -tags $(PKCS11_TAG) -v ./pkg/signing/...


test-all-tags: ## Test with all build tags
$(info Testing with all build tags)
go test -tags "$(SAML_TAG),$(OIDCRP_TAG),$(VC20_TAG),$(PKCS11_TAG), $(ZK_TAG)" -v ./...

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space before $(ZK_TAG) in the -tags list. Go's -tags flag expects a clean comma-separated list; the space can lead to an invalid/ignored tag depending on parsing. Remove the space to ensure zk is actually enabled when running this target.

Suggested change
go test -tags "$(SAML_TAG),$(OIDCRP_TAG),$(VC20_TAG),$(PKCS11_TAG), $(ZK_TAG)" -v ./...
go test -tags "$(SAML_TAG),$(OIDCRP_TAG),$(VC20_TAG),$(PKCS11_TAG),$(ZK_TAG)" -v ./...

Copilot uses AI. Check for mistakes.

# DIDComm v2.1 Test targets
test-didcomm: ## Test DIDComm v2.1 implementation
$(info Testing DIDComm v2.1 implementation)
Expand Down Expand Up @@ -347,6 +356,37 @@ endef

$(foreach service,$(WORKER_SERVICES),$(eval $(call DOCKER_BUILD_WORKER_TEMPLATE,$(service))))


docker-build-verifier: _check-reserved-tag ## Build Docker image for verifier with ZK support
$(info Building Docker image 'verifier' with ZK support)
go mod tidy
go mod vendor
docker build --build-arg SERVICE_NAME=verifier \
--build-arg GO_BUILD_TAGS=$(ZK_TAG) \
--tag verifier \
--file dockerfiles/verifier.Dockerfile .

docker-build-apigw-saml: _check-reserved-tag ## Build apigw Docker image with SAML support
$(info Docker building apigw with SAML support, tag: $(VERSION))
docker build --build-arg SERVICE_NAME=apigw --build-arg BUILDTAG=$(VERSION) \
--build-arg GO_BUILD_TAGS=$(SAML_TAG) \
--tag $(call docker-tag,apigw-saml,$(VERSION)) \
--file dockerfiles/worker .

docker-build-apigw-oidcrp: _check-reserved-tag ## Build apigw Docker image with OIDC RP support
$(info Docker building apigw with OIDC RP support, tag: $(VERSION))
docker build --build-arg SERVICE_NAME=apigw --build-arg BUILDTAG=$(VERSION) \
--build-arg GO_BUILD_TAGS=$(OIDCRP_TAG) \
--tag $(call docker-tag,apigw-oidcrp,$(VERSION)) \
--file dockerfiles/worker .

docker-build-apigw-all: _check-reserved-tag ## Build apigw Docker image with all features
$(info Docker building apigw with all features - SAML and OIDC RP, tag: $(VERSION))
docker build --build-arg SERVICE_NAME=apigw --build-arg BUILDTAG=$(VERSION) \
--build-arg GO_BUILD_TAGS="$(ALL_TAGS)" \
--tag $(call docker-tag,apigw-full,$(VERSION)) \
--file dockerfiles/worker .

# Docker build with PKCS#11 feature
docker-build-issuer-hsm: _check-reserved-tag ## Build issuer Docker image with PKCS#11 HSM support
$(info Docker building issuer with PKCS#11 HSM support, tag: $(VERSION))
Expand Down Expand Up @@ -792,4 +832,4 @@ release-demo: ## Promote a release tag to demo
$(MAKE) docker-push VERSION=demo _RELEASE_MODE=1; \
echo ""; \
echo "==> Demo promotion complete for $$SRC_TAG (:demo)"; \
echo ""
echo ""
7 changes: 7 additions & 0 deletions cmd/verifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ func main() {
)

cfg, err := configuration.New(ctx, serviceName)

if err != nil {
panic(err)
}
if cfg.Verifier == nil {
panic("Verifier section is missing from config")
}
if err := setupZK(cfg); err != nil {
panic(err)
}

if cfg.Verifier == nil {
panic("verifier configuration is required but not found in config file")
Expand Down
11 changes: 11 additions & 0 deletions cmd/verifier/zk_disabled_setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build !zk

package main

import (
"vc/pkg/model"
)

func setupZK(cfg *model.Cfg) error {
return nil
}
26 changes: 26 additions & 0 deletions cmd/verifier/zk_enabled_setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//go:build zk

package main

import (
"fmt"
"os"
"proofs/server/v2/zk"
"vc/pkg/model"
)

func setupZK(cfg *model.Cfg) error {
if cfg.Verifier == nil || cfg.Verifier.ZK.CircuitsPath == "" || cfg.Verifier.ZK.CACertsPath == "" {
return fmt.Errorf("ZK build requires circuits_path and cacerts_path in config")
}
zk.LoadCircuits(cfg.Verifier.ZK.CircuitsPath)
Comment on lines +13 to +16

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setupZK ignores the error return from zk.LoadCircuits(...), so verifier startup will succeed even if circuits fail to load (and later verification requests will fail unexpectedly). Also cfg.Verifier.ZK.LibPath is required in config but never used here. Please handle/return the LoadCircuits error and either remove LibPath from config or use it (e.g., to configure library search path) so the config contract matches behavior.

Suggested change
if cfg.Verifier == nil || cfg.Verifier.ZK.CircuitsPath == "" || cfg.Verifier.ZK.CACertsPath == "" {
return fmt.Errorf("ZK build requires circuits_path and cacerts_path in config")
}
zk.LoadCircuits(cfg.Verifier.ZK.CircuitsPath)
if cfg.Verifier == nil || cfg.Verifier.ZK.CircuitsPath == "" || cfg.Verifier.ZK.CACertsPath == "" || cfg.Verifier.ZK.LibPath == "" {
return fmt.Errorf("ZK build requires circuits_path, cacerts_path, and lib_path in config")
}
if err := os.Setenv("LD_LIBRARY_PATH", cfg.Verifier.ZK.LibPath); err != nil {
return fmt.Errorf("could not set ZK library path: %w", err)
}
if err := zk.LoadCircuits(cfg.Verifier.ZK.CircuitsPath); err != nil {
return fmt.Errorf("could not load ZK circuits: %w", err)
}

Copilot uses AI. Check for mistakes.
pem, err := os.ReadFile(cfg.Verifier.ZK.CACertsPath)
if err != nil {
return fmt.Errorf("could not read ZK cacerts file: %w", err)
}
if err := zk.LoadIssuerRootCA(pem); err != nil {
return fmt.Errorf("could not load issuer root CA: %w", err)
}

return nil
}
23 changes: 21 additions & 2 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ common:
auth_scopes: ["pid_1_5", "pid_1_8", "eduid"]
auth_claims: ["given_name", "birthdate", "family_name"]
format: "dc+sd-jwt"
mdl_pid:
vct: "urn:eudi:pid:1"
vctm_file_path: "/metadata/vctm_pid_arf_1_5.json" # Or your mdoc metadata
auth_method: "basic"
format: "mso_mdoc"

kafka:
enable: false
Expand All @@ -96,16 +101,18 @@ kafka:
- "kafka1:9092"

issuer:
issuer_url: "http://apigw.vc.docker:8080"
identifier: "https://issuer.sunet.se"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

identifier is not used anymore.

wallet_url: ""
issuer_url: "http://apigw.vc.docker:8080"
signing_key_path: "/pki/signing_ec_private.pem"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use key_config, it has capability to use pkcs11 as well as crypto material on disk.

api_server:
addr: :8080
grpc_server:
addr: issuer.vc.docker:8090
registry_client:
addr: registry.vc.docker:8090
audit_log:
enable: false
enabled: false

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

audit_log uses enabled, but the config model uses yaml:"enable" for this setting. As a result, this sample config will silently leave audit logging at the default rather than applying the intended value. Rename enabled back to enable (or update the model if the field name is meant to change).

Suggested change
enabled: false
enable: false

Copilot uses AI. Check for mistakes.
destinations:
- "console"
- "/var/log/vc/audit.log"
Expand All @@ -130,6 +137,14 @@ issuer:
valid_duration: 3600
verifiable_credential_type: "https://credential.sunet.se/identity_credential"
static_host: "http://vc_dev_portal:8080/statics"
mdoc:
valid_duration: 3600
signing_key_path: "/pki/signing_ec_private.pem"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use key_config

# This must match the DocType in your curl
doc_type: "org.iso.18013.5.1.mDL"
certificate_chain_path: "/pki/signing_ec_chain.pem"
# This is the namespace your Rust code expects

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what rust code?

namespace: "org.iso.18013.5.1"

verifier:
api_server:
Expand Down Expand Up @@ -240,6 +255,10 @@ verifier:
- vct: "urn:credential:eduid:1"
scopes:
- "eduid"
zk:
ca_certs_path: "/app/vc/internal/verifier/zk/certs.pem"
circuits_path: "/app/vc/internal/verifier/zk/circuits/"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is circuits_path the same as a path to a lib?

lib_path: "/usr/local/lib"

registry:
api_server:
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ services:
verifier:
container_name: "vc_dev_verifier"
hostname: "verifier.vc.docker"
image: docker.sunet.se/iam_vc/verifier:local
image: verifier

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the complete path please

restart: always
volumes:
- ./config_minimal.yaml:/config.yaml:ro
Expand Down
45 changes: 45 additions & 0 deletions dockerfiles/verifier.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# --- Stage 1: Build C++ ZK Libraries and Go Binary ---
FROM golang:latest AS builder

Check warning on line 2 in dockerfiles/verifier.Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a specific version tag for the image.

See more on https://sonarcloud.io/project/issues?id=SUNET_vc&issues=AZ0Ra-5HNfgQaKDpGJPR&open=AZ0Ra-5HNfgQaKDpGJPR&pullRequest=327

RUN apt update -y && apt install -y \
clang cmake libssl-dev libzstd-dev libgtest-dev \
libbenchmark-dev zlib1g-dev build-essential git

# 1. Clone the external dependency
RUN git clone https://github.com/google/longfellow-zk.git /tmp/longfellow-zk && \
cd /tmp/longfellow-zk && \
git checkout 66fab34ac83bdb669be35ca380e16191468e96d4

WORKDIR /tmp/longfellow-zk

RUN CXX=clang++ cmake -D CMAKE_BUILD_TYPE=Release -S lib -B build \
--install-prefix /usr/local/zk-install && \
cd build && make -j$(nproc) install

WORKDIR /app
COPY . .
ARG GO_BUILD_TAGS
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=1 \
CGO_CFLAGS="-I/usr/local/zk-install/include" \
CGO_LDFLAGS="-L/usr/local/zk-install/lib -lmdoc_static -lcrypto -lzstd -lstdc++" \
go build -mod=vendor -v \
-tags "${GO_BUILD_TAGS}" \
-o /app/bin/vc_verifier ./cmd/verifier/

# --- Stage 2: Final Runtime Image ---
FROM docker.sunet.se/iam_vc/verifier:latest

Check warning on line 31 in dockerfiles/verifier.Dockerfile

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use a specific version tag for the image.

See more on https://sonarcloud.io/project/issues?id=SUNET_vc&issues=AZ0Ra-5HNfgQaKDpGJPS&open=AZ0Ra-5HNfgQaKDpGJPS&pullRequest=327

RUN apt update -y && apt install -y libssl3 libzstd1 zlib1g && rm -rf /var/lib/apt/lists/*

# Copy the binary
COPY --from=builder /app/bin/vc_verifier /usr/local/bin/verifier
COPY --from=builder /tmp/longfellow-zk/lib/circuits /app/vc/internal/verifier/zk/circuits/
COPY --from=builder /tmp/longfellow-zk/reference/verifier-service/server/certs.pem /app/vc/internal/verifier/zk/certs.pem

# Copy compiled libraries
COPY --from=builder /usr/local/zk-install/lib /usr/local/lib/
RUN ldconfig

WORKDIR /
ENTRYPOINT ["/usr/local/bin/verifier"]
7 changes: 3 additions & 4 deletions dockerfiles/worker
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ ARG GO_BUILD_TAGS
# Copy only dependency files first for better caching
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go mod download

--mount=type=cache,target=/go/pkg/mod
COPY vendor/ ./vendor/
Comment on lines 10 to +12

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RUN instruction here has no command (it ends after the --mount flags), which will cause the Docker build to fail with a syntax/runtime error. Either restore a command (e.g., go mod download) or remove the RUN line entirely if vendoring is intended.

Copilot uses AI. Check for mistakes.
# Copy source code
COPY . .

Expand All @@ -22,7 +21,7 @@ RUN make proto
# GO_BUILD_TAGS is optional - if set, adds -tags flag
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=linux GOARCH=amd64 go build -v ${GO_BUILD_TAGS:+-tags "$GO_BUILD_TAGS"} -o bin/vc_$SERVICE_NAME -ldflags \
GOOS=linux GOARCH=amd64 go build -mod=vendor -v ${GO_BUILD_TAGS:+-tags "$GO_BUILD_TAGS"} -o bin/vc_$SERVICE_NAME -ldflags \
"-X vc/pkg/model.BuildVariableGitCommit=$(git rev-list -1 HEAD) \
-X vc/pkg/model.BuildVariableGitBranch=$(git rev-parse --abbrev-ref HEAD) \
-X vc/pkg/model.BuildVariableTimestamp=$(date +'%F:T%TZ') \
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ require (
gopkg.in/yaml.v2 v2.4.0
gorm.io/gorm v1.31.1
gotest.tools/v3 v3.5.2
proofs/server/v2 v2.0.0
)

require (
Expand Down Expand Up @@ -213,3 +214,5 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20260316180232-0b37fe3546d5 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace proofs/server/v2 => /tmp/longfellow-zk/reference/verifier-service/server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

34 changes: 34 additions & 0 deletions internal/issuer/apiv1/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"vc/internal/gen/issuer/apiv1_issuer"
"vc/pkg/logger"

"context"
"encoding/hex"

"vc/pkg/mdoc"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -602,3 +607,32 @@
})
}
}

func TestMakeMDoc_Only(t *testing.T) {

Check warning on line 611 in internal/issuer/apiv1/handlers_test.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename function "TestMakeMDoc_Only" to match the regular expression ^(_|[a-zA-Z0-9]+)$

See more on https://sonarcloud.io/project/issues?id=SUNET_vc&issues=AZ0SD4IEEnrKnygjowrq&open=AZ0SD4IEEnrKnygjowrq&pullRequest=327

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only what?

ctx := context.Background()
log := logger.NewSimple("test")
client := mockNewClient(ctx, t, "ecdsa", log)

realIssuer := &mdoc.Issuer{}

client.mdocIssuer = realIssuer

deviceKeyHex := "a501020326200121582065eda5bd2d497ef0d35502f5846014e4a66a17ef65476a029587428f6426466322582042f4c664323c932a393086603a1f81d894e77227ed9097e38317769539257609"
deviceKeyBytes, _ := hex.DecodeString(deviceKeyHex)

req := &CreateMDocRequest{
Scope: "mdl",
DocType: "org.iso.18013.5.1.mDL",
DocumentData: []byte(`{"given_name": "John"}`),
DevicePublicKey: deviceKeyBytes,
DeviceKeyFormat: "cose",
}

got, err := client.MakeMDoc(ctx, req)
if err != nil {
t.Logf("Note: Real issuer failed (likely missing keys): %v", err)
} else {
require.NoError(t, err)
assert.NotNil(t, got)
}
Comment on lines +611 to +637

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test logs and continues on error, so it can pass even if MakeMDoc is broken (and it likely will fail in many environments if signing keys/config aren't present). To make it meaningful, either fully mock mdoc.Issuer and assert deterministic behavior, or turn this into an explicit integration test that is skipped unless required test fixtures/env are present.

Copilot uses AI. Check for mistakes.
}
10 changes: 10 additions & 0 deletions internal/issuer/httpserver/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"go.opentelemetry.io/otel/codes"

"github.com/gin-gonic/gin"

"vc/internal/issuer/apiv1"
)

func (s *Service) endpointHealth(ctx context.Context, c *gin.Context) (any, error) {
Expand All @@ -21,3 +23,11 @@ func (s *Service) endpointHealth(ctx context.Context, c *gin.Context) (any, erro
}
return reply, nil
}

func (s *Service) endpointMakeMDoc(ctx context.Context, c *gin.Context) (any, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not be exposed via http, only grpc

req := &apiv1.CreateMDocRequest{}
if err := c.ShouldBindJSON(req); err != nil {
return nil, err
}
return s.apiv1.MakeMDoc(ctx, req)
}
3 changes: 2 additions & 1 deletion internal/issuer/httpserver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Service struct {
cfg *model.Cfg
log *logger.Log
server *http.Server
apiv1 Apiv1
apiv1 *apiv1.Client

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use interface, not struct.

gin *gin.Engine
tracer *trace.Tracer
httpHelpers *httphelpers.Client
Comment on lines 22 to 28

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switching Service.apiv1 from an interface to a concrete *apiv1.Client reduces testability and bypasses the existing internal/issuer/httpserver/api.go abstraction. Instead, extend the Apiv1 interface to include MakeMDoc and keep Service.apiv1 typed as that interface so handlers can be unit-tested with mocks.

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -51,6 +51,7 @@ func New(ctx context.Context, cfg *model.Cfg, apiv1 *apiv1.Client, tracer *trace
}

s.httpHelpers.Server.RegEndpoint(ctx, rgRoot, http.MethodGet, "health", http.StatusOK, s.endpointHealth)
s.httpHelpers.Server.RegEndpoint(ctx, rgRoot, http.MethodPost, "mdoc", http.StatusOK, s.endpointMakeMDoc)

rgDocs := rgRoot.Group("/swagger")
rgDocs.GET("/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
Expand Down
Loading
Loading