feat(assessment): add the review band of attempt signals and the disclosed collector

This commit is contained in:
shira committed 2026-10-08 23:04:57 +03:00
1 parent 68286af8b7
commit b3c6dc870b
124 files changed
+13522 -633

No files matched your search

@@ -0,0 +1,133 @@
// Package assessmentreview implements the local operator command that prints
// the stored manual-review band of an assessment attempt. The band is never
// served over HTTP; this command is the only reader until staff roles exist.
package assessmentreview
import (
"context"
"errors"
"flag"
"fmt"
"io"
"strings"
"time"
"github.com/google/uuid"
"lincodex/backend/config"
"lincodex/backend/internal/adapter/secondary/postgres"
"lincodex/backend/internal/domain"
"lincodex/backend/internal/port/outbound"
"lincodex/backend/internal/usecase/assessment"
)
const usage = "usage: assessment-review inspect --attempt <uuid> --actor operator:<handle>"
// Command is a parsed, validated review inspection.
type Command struct {
AttemptID domain.AssessmentAttemptID
Actor string
}
// Operator reads a review and records the read.
type Operator interface {
Inspect(ctx context.Context, attemptID domain.AssessmentAttemptID, actor string) (domain.AssessmentAttemptReview, error)
}
// Parse validates every argument before Run reads configuration or connects
// to PostgreSQL.
func Parse(args []string) (Command, error) {
if len(args) == 0 || args[0] != "inspect" {
return Command{}, errors.New(usage)
}
flags := flag.NewFlagSet("assessment-review inspect", flag.ContinueOnError)
flags.SetOutput(io.Discard)
attempt := flags.String("attempt", "", "attempt UUID")
actor := flags.String("actor", "", "operator handle")
if err := flags.Parse(args[1:]); err != nil || flags.NArg() != 0 {
return Command{}, errors.New(usage)
}
attemptID, err := uuid.Parse(strings.TrimSpace(*attempt))
if err != nil || attemptID == uuid.Nil {
return Command{}, errors.New("attempt must be a non-zero UUID")
}
if _, err := domain.ParseAssessmentReviewActor(strings.TrimSpace(*actor)); err != nil {
return Command{}, errors.New("actor must be operator:<handle>")
}
return Command{AttemptID: domain.AssessmentAttemptID(attemptID), Actor: strings.TrimSpace(*actor)}, nil
}
// Run parses the command, loads only DATABASE_URL from the supplied
// environment, and executes the operator usecase. It does not load dotenv
// files.
func Run(ctx context.Context, args []string, lookup config.LookupEnv, output io.Writer) error {
command, err := Parse(args)
if err != nil {
return err
}
if lookup == nil || output == nil {
return errors.New("assessment review command dependencies are required")
}
databaseURL := config.DatabaseURLFromEnv(lookup)
if databaseURL == "" {
return errors.New("DATABASE_URL is not set")
}
pool, err := postgres.NewPool(ctx, databaseURL)
if err != nil {
return errors.New("database configuration is invalid")
}
defer pool.Close()
if err := pool.Ping(ctx); err != nil {
return errors.New("database is unavailable")
}
operator, err := assessment.NewReviewOperator(postgres.NewTransactor(pool))
if err != nil {
return errors.New("assessment review is unavailable")
}
return Execute(ctx, command, operator, output)
}
// Execute prints the review. The output holds counts, durations, the band, the
// reason codes, and the policy version; it holds no answer, address, session,
// candidate, or contact data.
func Execute(ctx context.Context, command Command, operator Operator, output io.Writer) error {
if operator == nil || output == nil {
return errors.New("assessment review command dependencies are required")
}
review, err := operator.Inspect(ctx, command.AttemptID, command.Actor)
if err != nil {
return safeOperationError(err)
}
reasons := make([]string, 0, len(review.Outcome.Reasons))
for _, reason := range review.Outcome.Reasons {
reasons = append(reasons, string(reason))
}
measures := review.Measures
if _, err := fmt.Fprintf(output,
"attempt: %s\nband: %s\nreasons: %s\npolicy_version: %d\nevaluated_at: %s\nupdated_at: %s\n"+
"answered_items: %d\nfast_answers: %d\ndeviating_answers: %d\nparallel_alternations: %d\nextra_networks: %d\n"+
"matched_integer_items: %d\nmatched_sequence_items: %d\nduplicate_evidence_bits: %d\n"+
"client_focus_loss_ms: %d\nclient_clipboard_events: %d\nclient_fullscreen_exits: %d\n"+
"note: a hint for a manual check; it changes no result, category, or quota, and browser signals can be forged\n",
review.AttemptID, review.Outcome.Band, strings.Join(reasons, ","), review.PolicyVersion,
review.EvaluatedAt.UTC().Format(time.RFC3339), review.UpdatedAt.UTC().Format(time.RFC3339),
measures.AnsweredItems, measures.FastAnswers, measures.DeviatingAnswers, measures.ParallelAlternations,
measures.ExtraNetworks, measures.MatchedIntegerItems, measures.MatchedSequenceItems,
measures.DuplicateEvidenceBits, measures.ClientFocusLossMS, measures.ClientClipboardEvents,
measures.ClientFullscreenExits,
); err != nil {
return errors.New("could not write the review")
}
return nil
}
func safeOperationError(err error) error {
switch {
case errors.Is(err, outbound.ErrAssessmentReviewNotFound):
return errors.New("attempt has no review (the read was recorded)")
case errors.Is(err, domain.ErrInvalidAssessmentReview):
return errors.New("attempt or actor is invalid")
default:
return errors.New("assessment review operation failed")
}
}
@@ -0,0 +1,113 @@
package assessmentreview
import (
"bytes"
"context"
"errors"
"strings"
"testing"
"time"
"github.com/google/uuid"
"lincodex/backend/config"
"lincodex/backend/internal/domain"
"lincodex/backend/internal/port/outbound"
)
type operatorFake struct {
review domain.AssessmentAttemptReview
err error
calls int
actor string
}
func (operator *operatorFake) Inspect(_ context.Context, _ domain.AssessmentAttemptID, actor string) (domain.AssessmentAttemptReview, error) {
operator.calls++
operator.actor = actor
return operator.review, operator.err
}
func TestParseRequiresAnAttemptAndAnOperatorHandle(t *testing.T) {
id := uuid.New().String()
command, err := Parse([]string{"inspect", "--attempt", id, "--actor", "operator:night"})
if err != nil || command.AttemptID.String() != id || command.Actor != "operator:night" {
t.Fatalf("Parse(valid) = %+v, %v", command, err)
}
for _, args := range [][]string{
nil,
{"list"},
{"inspect"},
{"inspect", "--attempt", id},
{"inspect", "--attempt", id, "--actor", "alice"},
{"inspect", "--attempt", "not-a-uuid", "--actor", "operator:night"},
{"inspect", "--attempt", uuid.Nil.String(), "--actor", "operator:night"},
{"inspect", "--attempt", id, "--actor", "operator:night", "extra"},
} {
if _, err := Parse(args); err == nil {
t.Errorf("Parse(%v) accepted invalid arguments", args)
}
}
}
func TestRunValidatesArgumentsBeforeReadingTheEnvironment(t *testing.T) {
lookup := func(string) (string, bool) {
t.Fatal("environment read before arguments were validated")
return "", false
}
if err := Run(context.Background(), []string{"inspect"}, lookup, &bytes.Buffer{}); err == nil {
t.Fatal("Run(invalid arguments) succeeded")
}
var noDatabase config.LookupEnv = func(string) (string, bool) { return "", false }
err := Run(context.Background(), []string{"inspect", "--attempt", uuid.New().String(), "--actor", "operator:night"}, noDatabase, &bytes.Buffer{})
if err == nil || !strings.Contains(err.Error(), "DATABASE_URL") {
t.Fatalf("Run(no database) error = %v, want a DATABASE_URL message", err)
}
}
func TestExecutePrintsOnlyBandCountsAndReasons(t *testing.T) {
attemptID := domain.AssessmentAttemptID(uuid.New())
operator := &operatorFake{review: domain.AssessmentAttemptReview{
AttemptID: attemptID, PolicyVersion: 4,
Measures: domain.AssessmentReviewMeasures{AnsweredItems: 9, FastAnswers: 5, ParallelAlternations: 2, ExtraNetworks: 1, MatchedIntegerItems: 3, DuplicateEvidenceBits: 9},
Outcome: domain.AssessmentReviewOutcome{
Band: domain.AssessmentReviewBandAttention,
Reasons: []domain.AssessmentReviewReason{domain.AssessmentReviewReasonFastAnswers, domain.AssessmentReviewReasonParallelSessions},
},
EvaluatedAt: time.Date(2026, time.October, 1, 10, 0, 0, 0, time.UTC), UpdatedAt: time.Date(2026, time.October, 2, 10, 0, 0, 0, time.UTC),
}}
var output bytes.Buffer
command := Command{AttemptID: attemptID, Actor: "operator:night"}
if err := Execute(context.Background(), command, operator, &output); err != nil {
t.Fatalf("Execute() error = %v", err)
}
for _, want := range []string{"attempt: " + attemptID.String(), "band: attention", "reasons: fast_answers,parallel_sessions", "policy_version: 4", "fast_answers: 5", "matched_integer_items: 3", "extra_networks: 1", "duplicate_evidence_bits: 9", "a hint for a manual check"} {
if !strings.Contains(output.String(), want) {
t.Errorf("output lacks %q:\n%s", want, output.String())
}
}
for _, forbidden := range []string{"user", "email", "address", "session", "answer:", "fingerprint"} {
if strings.Contains(output.String(), forbidden+":") {
t.Errorf("output has a %q line:\n%s", forbidden, output.String())
}
}
if operator.calls != 1 || operator.actor != "operator:night" {
t.Fatalf("operator calls/actor = %d/%q, want one call with the handle", operator.calls, operator.actor)
}
}
func TestExecuteMapsFailuresToSafeMessages(t *testing.T) {
for _, test := range []struct {
err error
want string
}{
{outbound.ErrAssessmentReviewNotFound, "no review"},
{domain.ErrInvalidAssessmentReview, "invalid"},
{errors.New("pq: password authentication failed for user lincodex at 10.0.0.5"), "operation failed"},
} {
err := Execute(context.Background(), Command{}, &operatorFake{err: test.err}, &bytes.Buffer{})
if err == nil || !strings.Contains(err.Error(), test.want) || strings.Contains(err.Error(), "10.0.0.5") {
t.Errorf("Execute(%v) error = %v, want a safe %q message", test.err, err, test.want)
}
}
}
@@ -320,6 +320,239 @@ func (s *Server) handleAcceptMyInvitationRequest(args [1]string, argsEscaped boo
}
}
// handleAcknowledgeMyAssessmentSignalNoticeRequest handles AcknowledgeMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email, the CSRF token of that
// session in X-CSRF-Token, and an allowed Origin. The body carries the notice version the candidate
// was shown. The server stores the acknowledgement for the account and that version; the response
// carries the server time of the first acknowledgement.
//
// The operation needs no Idempotency-Key: it is idempotent. Repeating it for an acknowledged version
// changes nothing, keeps the first time, and answers 200, so a retry after a lost response succeeds. A
// version other than the one the server requires answers 409 state_conflict and stores nothing; the
// client reads the notice again.
//
// The acknowledgement is not a consent. It does not grant, replace, or hide C3, and it does not affect
// the signal operation or any score, category, or quota. The body carries no signal, answer, or
// clipboard data.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account (403 forbidden), then the version (409).
//
// PUT /api/v1/me/assessment-signal-notice
func (s *Server) handleAcknowledgeMyAssessmentSignalNoticeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("AcknowledgeMyAssessmentSignalNotice"),
semconv.HTTPRequestMethodKey.String("PUT"),
semconv.HTTPRouteKey.String("/api/v1/me/assessment-signal-notice"),
}
// Add attributes from config.
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), AcknowledgeMyAssessmentSignalNoticeOperation,
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Add Labeler to context.
labeler := &Labeler{attrs: otelAttrs}
ctx = contextWithLabeler(ctx, labeler)
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
code := statusWriter.status
if code != 0 {
codeAttr := semconv.HTTPResponseStatusCode(code)
attrs = append(attrs, codeAttr)
span.SetAttributes(attrs...)
}
attrOpt := metric.WithAttributes(attrs...)
// Increment request counter.
s.requests.Add(ctx, 1, attrOpt)
// Use floating point division here for higher precision (instead of Millisecond method).
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
}()
var (
recordError = func(stage string, err error) {
span.RecordError(err)
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
// max redirects exceeded), in which case status MUST be set to Error.
code := statusWriter.status
if code < 100 || code >= 500 {
span.SetStatus(codes.Error, stage)
}
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
if code != 0 {
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
}
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
}
err error
opErrContext = ogenerrors.OperationContext{
Name: AcknowledgeMyAssessmentSignalNoticeOperation,
ID: "AcknowledgeMyAssessmentSignalNotice",
}
)
{
type bitset = [1]uint8
var satisfied bitset
{
sctx, ok, err := s.securitySessionCookie(ctx, AcknowledgeMyAssessmentSignalNoticeOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCookie",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCookie", err)
}
return
}
if ok {
satisfied[0] |= 1 << 0
ctx = sctx
}
}
{
sctx, ok, err := s.securitySessionCsrf(ctx, AcknowledgeMyAssessmentSignalNoticeOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCsrf",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCsrf", err)
}
return
}
if ok {
satisfied[0] |= 1 << 1
ctx = sctx
}
}
if ok := func() bool {
nextRequirement:
for _, requirement := range []bitset{
{0b00000011},
} {
for i, mask := range requirement {
if satisfied[i]&mask != mask {
continue nextRequirement
}
}
return true
}
return false
}(); !ok {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security", err)
}
return
}
}
var rawBody []byte
request, rawBody, close, err := s.decodeAcknowledgeMyAssessmentSignalNoticeRequest(r)
if err != nil {
err = &ogenerrors.DecodeRequestError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeRequest", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
defer func() {
if err := close(); err != nil {
recordError("CloseRequest", err)
}
}()
var response AcknowledgeMyAssessmentSignalNoticeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: AcknowledgeMyAssessmentSignalNoticeOperation,
OperationSummary: "Record that the current candidate read the signal notice.",
OperationID: "AcknowledgeMyAssessmentSignalNotice",
Body: request,
RawBody: rawBody,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = *AssessmentSignalNoticeAcknowledgement
Params = struct{}
Response = AcknowledgeMyAssessmentSignalNoticeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.AcknowledgeMyAssessmentSignalNotice(ctx, request)
return response, err
},
)
} else {
response, err = s.h.AcknowledgeMyAssessmentSignalNotice(ctx, request)
}
if err != nil {
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
if err := encodeErrorResponse(errRes, w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if errors.Is(err, ht.ErrNotImplemented) {
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if err := encodeAcknowledgeMyAssessmentSignalNoticeResponse(response, w, span); err != nil {
defer recordError("EncodeResponse", err)
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
s.cfg.ErrorHandler(ctx, w, r, err)
}
return
}
}
// handleCancelMyInvitationRequest handles CancelMyInvitation operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -4056,6 +4289,209 @@ func (s *Server) handleGetMyAssessmentResultRequest(args [1]string, argsEscaped
}
}
// handleGetMyAssessmentSignalNoticeRequest handles GetMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email; the candidate comes from
// the session. Returns the notice version that the server requires now and whether this candidate
// acknowledged it. The notice lists the signals that are collected during a real assessment attempt
// and states that images, sound, and clipboard contents are not collected. Client signals are the time
// away from the tab or window, copy, paste and cut with a size only, and exits from fullscreen mode.
// Server signals are the response time of each item measured by the server, a change of network
// address during the attempt, parallel sessions, and the comparison of answers to variants of the same
// task by candidates. The server stores for these only one-way keyed digests: it stores no network
// address, no session token, and no answer text. Client signals are stored only while the C3 consent
// is current. The client shows it before a real attempt starts and does not start the attempt until
// the notice is acknowledged.
//
// The acknowledgement is stored on the server per account and notice version, so it survives a reload
// and a new browser. It is not a consent and never changes C3: the signal operation still requires a
// current C3 consent, and an unacknowledged notice does not make that operation fail. The demo_express
// training mode collects no signals and needs no acknowledgement.
//
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account or
// an unconfirmed email answers 403 forbidden.
//
// GET /api/v1/me/assessment-signal-notice
func (s *Server) handleGetMyAssessmentSignalNoticeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("GetMyAssessmentSignalNotice"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/api/v1/me/assessment-signal-notice"),
}
// Add attributes from config.
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), GetMyAssessmentSignalNoticeOperation,
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Add Labeler to context.
labeler := &Labeler{attrs: otelAttrs}
ctx = contextWithLabeler(ctx, labeler)
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
code := statusWriter.status
if code != 0 {
codeAttr := semconv.HTTPResponseStatusCode(code)
attrs = append(attrs, codeAttr)
span.SetAttributes(attrs...)
}
attrOpt := metric.WithAttributes(attrs...)
// Increment request counter.
s.requests.Add(ctx, 1, attrOpt)
// Use floating point division here for higher precision (instead of Millisecond method).
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
}()
var (
recordError = func(stage string, err error) {
span.RecordError(err)
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
// max redirects exceeded), in which case status MUST be set to Error.
code := statusWriter.status
if code < 100 || code >= 500 {
span.SetStatus(codes.Error, stage)
}
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
if code != 0 {
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
}
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
}
err error
opErrContext = ogenerrors.OperationContext{
Name: GetMyAssessmentSignalNoticeOperation,
ID: "GetMyAssessmentSignalNotice",
}
)
{
type bitset = [1]uint8
var satisfied bitset
{
sctx, ok, err := s.securitySessionCookie(ctx, GetMyAssessmentSignalNoticeOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCookie",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCookie", err)
}
return
}
if ok {
satisfied[0] |= 1 << 0
ctx = sctx
}
}
if ok := func() bool {
nextRequirement:
for _, requirement := range []bitset{
{0b00000001},
} {
for i, mask := range requirement {
if satisfied[i]&mask != mask {
continue nextRequirement
}
}
return true
}
return false
}(); !ok {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security", err)
}
return
}
}
var rawBody []byte
var response GetMyAssessmentSignalNoticeRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: GetMyAssessmentSignalNoticeOperation,
OperationSummary: "Read whether the current candidate acknowledged the signal notice.",
OperationID: "GetMyAssessmentSignalNotice",
Body: nil,
RawBody: rawBody,
Params: middleware.Parameters{},
Raw: r,
}
type (
Request = struct{}
Params = struct{}
Response = GetMyAssessmentSignalNoticeRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
nil,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.GetMyAssessmentSignalNotice(ctx)
return response, err
},
)
} else {
response, err = s.h.GetMyAssessmentSignalNotice(ctx)
}
if err != nil {
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
if err := encodeErrorResponse(errRes, w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if errors.Is(err, ht.ErrNotImplemented) {
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if err := encodeGetMyAssessmentSignalNoticeResponse(response, w, span); err != nil {
defer recordError("EncodeResponse", err)
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
s.cfg.ErrorHandler(ctx, w, r, err)
}
return
}
}
// handleGetMyCardPreviewRequest handles GetMyCardPreview operation.
//
// Requires the session cookie of a candidate account. Returns a private preview of the permitted
@@ -7265,6 +7701,219 @@ func (s *Server) handleHideOrganizationRequest(args [1]string, argsEscaped bool,
}
}
// handleListMyAssessmentResultsRequest handles ListMyAssessmentResults operation.
//
// Requires a candidate session. Returns only completed root and corrective results owned by this
// candidate, newest first by decided_at and attempt_id. demo_express training results never appear.
// The cursor is opaque and bound to this candidate and listing; a malformed or foreign cursor returns
// 400 validation_failed.
//
// A v2 result includes the category decision captured when that attempt ended, including the confirmed
// grade then in force. Legacy v1 results omit category_decision because a later category must not be
// projected backward. Later policy, bank, review, or category changes do not alter either result.
// Employers cannot read this history; their separate projection contains only the current permitted
// category and no answers.
//
// GET /api/v1/me/assessment-results
func (s *Server) handleListMyAssessmentResultsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("ListMyAssessmentResults"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/api/v1/me/assessment-results"),
}
// Add attributes from config.
otelAttrs = append(otelAttrs, s.cfg.Attributes...)
// Start a span for this request.
ctx, span := s.cfg.Tracer.Start(r.Context(), ListMyAssessmentResultsOperation,
trace.WithAttributes(otelAttrs...),
serverSpanKind,
)
defer span.End()
// Add Labeler to context.
labeler := &Labeler{attrs: otelAttrs}
ctx = contextWithLabeler(ctx, labeler)
// Run stopwatch.
startTime := time.Now()
defer func() {
elapsedDuration := time.Since(startTime)
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
code := statusWriter.status
if code != 0 {
codeAttr := semconv.HTTPResponseStatusCode(code)
attrs = append(attrs, codeAttr)
span.SetAttributes(attrs...)
}
attrOpt := metric.WithAttributes(attrs...)
// Increment request counter.
s.requests.Add(ctx, 1, attrOpt)
// Use floating point division here for higher precision (instead of Millisecond method).
s.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), attrOpt)
}()
var (
recordError = func(stage string, err error) {
span.RecordError(err)
// https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status
// Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges,
// unless there was another error (e.g., network error receiving the response body; or 3xx codes with
// max redirects exceeded), in which case status MUST be set to Error.
code := statusWriter.status
if code < 100 || code >= 500 {
span.SetStatus(codes.Error, stage)
}
attrSet := labeler.AttributeSet()
attrs := attrSet.ToSlice()
if code != 0 {
attrs = append(attrs, semconv.HTTPResponseStatusCode(code))
}
s.errors.Add(ctx, 1, metric.WithAttributes(attrs...))
}
err error
opErrContext = ogenerrors.OperationContext{
Name: ListMyAssessmentResultsOperation,
ID: "ListMyAssessmentResults",
}
)
{
type bitset = [1]uint8
var satisfied bitset
{
sctx, ok, err := s.securitySessionCookie(ctx, ListMyAssessmentResultsOperation, r)
if err != nil {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Security: "SessionCookie",
Err: err,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security:SessionCookie", err)
}
return
}
if ok {
satisfied[0] |= 1 << 0
ctx = sctx
}
}
if ok := func() bool {
nextRequirement:
for _, requirement := range []bitset{
{0b00000001},
} {
for i, mask := range requirement {
if satisfied[i]&mask != mask {
continue nextRequirement
}
}
return true
}
return false
}(); !ok {
err = &ogenerrors.SecurityError{
OperationContext: opErrContext,
Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied,
}
if encodeErr := encodeErrorResponse(s.h.NewError(ctx, err), w, span); encodeErr != nil {
defer recordError("Security", err)
}
return
}
}
params, err := decodeListMyAssessmentResultsParams(args, argsEscaped, r)
if err != nil {
err = &ogenerrors.DecodeParamsError{
OperationContext: opErrContext,
Err: err,
}
defer recordError("DecodeParams", err)
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
var rawBody []byte
var response ListMyAssessmentResultsRes
if m := s.cfg.Middleware; m != nil {
mreq := middleware.Request{
Context: ctx,
OperationName: ListMyAssessmentResultsOperation,
OperationSummary: "List immutable real assessment results of the current candidate.",
OperationID: "ListMyAssessmentResults",
Body: nil,
RawBody: rawBody,
Params: middleware.Parameters{
{
Name: "limit",
In: "query",
}: params.Limit,
{
Name: "cursor",
In: "query",
}: params.Cursor,
},
Raw: r,
}
type (
Request = struct{}
Params = ListMyAssessmentResultsParams
Response = ListMyAssessmentResultsRes
)
response, err = middleware.HookMiddleware[
Request,
Params,
Response,
](
m,
mreq,
unpackListMyAssessmentResultsParams,
func(ctx context.Context, request Request, params Params) (response Response, err error) {
response, err = s.h.ListMyAssessmentResults(ctx, params)
return response, err
},
)
} else {
response, err = s.h.ListMyAssessmentResults(ctx, params)
}
if err != nil {
if errRes, ok := errors.Into[*ProblemStatusCode](err); ok {
if err := encodeErrorResponse(errRes, w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if errors.Is(err, ht.ErrNotImplemented) {
s.cfg.ErrorHandler(ctx, w, r, err)
return
}
if err := encodeErrorResponse(s.h.NewError(ctx, err), w, span); err != nil {
defer recordError("Internal", err)
}
return
}
if err := encodeListMyAssessmentResultsResponse(response, w, span); err != nil {
defer recordError("EncodeResponse", err)
if !errors.Is(err, ht.ErrInternalServerErrorResponse) {
s.cfg.ErrorHandler(ctx, w, r, err)
}
return
}
}
// handleListMyCardAccessHistoryRequest handles ListMyCardAccessHistory operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
@@ -5,6 +5,10 @@ type AcceptMyInvitationRes interface {
acceptMyInvitationRes()
}
type AcknowledgeMyAssessmentSignalNoticeRes interface {
acknowledgeMyAssessmentSignalNoticeRes()
}
type CancelMyInvitationRes interface {
cancelMyInvitationRes()
}
@@ -65,6 +69,10 @@ type GetMyAssessmentResultRes interface {
getMyAssessmentResultRes()
}
type GetMyAssessmentSignalNoticeRes interface {
getMyAssessmentSignalNoticeRes()
}
type GetMyCardPreviewRes interface {
getMyCardPreviewRes()
}
@@ -121,6 +129,10 @@ type HideOrganizationRes interface {
hideOrganizationRes()
}
type ListMyAssessmentResultsRes interface {
listMyAssessmentResultsRes()
}
type ListMyCardAccessHistoryRes interface {
listMyCardAccessHistoryRes()
}
File diff suppressed because it is too large. Load diff
@@ -6,68 +6,71 @@ package api
type OperationName = string
const (
AcceptMyInvitationOperation OperationName = "AcceptMyInvitation"
CancelMyInvitationOperation OperationName = "CancelMyInvitation"
ConfirmEmailOperation OperationName = "ConfirmEmail"
CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt"
CreateMySupportCaseOperation OperationName = "CreateMySupportCase"
CreateOrganizationOperation OperationName = "CreateOrganization"
CreateOrganizationInvitationOperation OperationName = "CreateOrganizationInvitation"
CreateOrganizationNeedOperation OperationName = "CreateOrganizationNeed"
DeclineMyInvitationOperation OperationName = "DeclineMyInvitation"
FinalizeMyAssessmentAttemptOperation OperationName = "FinalizeMyAssessmentAttempt"
GetConsentTextOperation OperationName = "GetConsentText"
GetCurrentAccountOperation OperationName = "GetCurrentAccount"
GetCurrentSessionOperation OperationName = "GetCurrentSession"
GetHealthzOperation OperationName = "GetHealthz"
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
GetMyCardPreviewOperation OperationName = "GetMyCardPreview"
GetMyConsentTextOperation OperationName = "GetMyConsentText"
GetMyInvitationOperation OperationName = "GetMyInvitation"
GetMyPrivacySettingsOperation OperationName = "GetMyPrivacySettings"
GetMyProfileOperation OperationName = "GetMyProfile"
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
GetMySupportCaseOperation OperationName = "GetMySupportCase"
GetOrganizationOperation OperationName = "GetOrganization"
GetOrganizationCandidateCardOperation OperationName = "GetOrganizationCandidateCard"
GetOrganizationInvitationOperation OperationName = "GetOrganizationInvitation"
GetOrganizationInvitationContactsOperation OperationName = "GetOrganizationInvitationContacts"
GetOrganizationNeedOperation OperationName = "GetOrganizationNeed"
GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog"
GrantMyConsentOperation OperationName = "GrantMyConsent"
HideOrganizationOperation OperationName = "HideOrganization"
ListMyCardAccessHistoryOperation OperationName = "ListMyCardAccessHistory"
ListMyConsentsOperation OperationName = "ListMyConsents"
ListMyHiddenOrganizationsOperation OperationName = "ListMyHiddenOrganizations"
ListMyInvitationsOperation OperationName = "ListMyInvitations"
ListMyOrganizationsOperation OperationName = "ListMyOrganizations"
ListMyPrivacyHistoryOperation OperationName = "ListMyPrivacyHistory"
ListMySupportCasesOperation OperationName = "ListMySupportCases"
ListOrganizationInvitationsOperation OperationName = "ListOrganizationInvitations"
ListOrganizationNeedsOperation OperationName = "ListOrganizationNeeds"
LoginOperation OperationName = "Login"
LogoutOperation OperationName = "Logout"
RaiseOrganizationInvitationSalaryOperation OperationName = "RaiseOrganizationInvitationSalary"
RecordMyAssessmentAttemptSignalsOperation OperationName = "RecordMyAssessmentAttemptSignals"
RegisterAccountOperation OperationName = "RegisterAccount"
RequestMyAccountDeletionOperation OperationName = "RequestMyAccountDeletion"
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
RevokeMyConsentOperation OperationName = "RevokeMyConsent"
RevokeMyOrganizationContactConsentOperation OperationName = "RevokeMyOrganizationContactConsent"
SaveMyProfileOperation OperationName = "SaveMyProfile"
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
SearchOrganizationMatchesOperation OperationName = "SearchOrganizationMatches"
SendOrganizationInvitationOperation OperationName = "SendOrganizationInvitation"
SetMyPublicationOperation OperationName = "SetMyPublication"
SetMySearchStatusOperation OperationName = "SetMySearchStatus"
StartMyAssessmentAttemptSessionOperation OperationName = "StartMyAssessmentAttemptSession"
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
UnhideOrganizationOperation OperationName = "UnhideOrganization"
UpdateOrganizationOperation OperationName = "UpdateOrganization"
UpdateOrganizationInvitationOperation OperationName = "UpdateOrganizationInvitation"
UpdateOrganizationNeedOperation OperationName = "UpdateOrganizationNeed"
ViewMyInvitationOperation OperationName = "ViewMyInvitation"
WithdrawOrganizationInvitationOperation OperationName = "WithdrawOrganizationInvitation"
AcceptMyInvitationOperation OperationName = "AcceptMyInvitation"
AcknowledgeMyAssessmentSignalNoticeOperation OperationName = "AcknowledgeMyAssessmentSignalNotice"
CancelMyInvitationOperation OperationName = "CancelMyInvitation"
ConfirmEmailOperation OperationName = "ConfirmEmail"
CreateMyAssessmentAttemptOperation OperationName = "CreateMyAssessmentAttempt"
CreateMySupportCaseOperation OperationName = "CreateMySupportCase"
CreateOrganizationOperation OperationName = "CreateOrganization"
CreateOrganizationInvitationOperation OperationName = "CreateOrganizationInvitation"
CreateOrganizationNeedOperation OperationName = "CreateOrganizationNeed"
DeclineMyInvitationOperation OperationName = "DeclineMyInvitation"
FinalizeMyAssessmentAttemptOperation OperationName = "FinalizeMyAssessmentAttempt"
GetConsentTextOperation OperationName = "GetConsentText"
GetCurrentAccountOperation OperationName = "GetCurrentAccount"
GetCurrentSessionOperation OperationName = "GetCurrentSession"
GetHealthzOperation OperationName = "GetHealthz"
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
GetMyAssessmentSignalNoticeOperation OperationName = "GetMyAssessmentSignalNotice"
GetMyCardPreviewOperation OperationName = "GetMyCardPreview"
GetMyConsentTextOperation OperationName = "GetMyConsentText"
GetMyInvitationOperation OperationName = "GetMyInvitation"
GetMyPrivacySettingsOperation OperationName = "GetMyPrivacySettings"
GetMyProfileOperation OperationName = "GetMyProfile"
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
GetMySupportCaseOperation OperationName = "GetMySupportCase"
GetOrganizationOperation OperationName = "GetOrganization"
GetOrganizationCandidateCardOperation OperationName = "GetOrganizationCandidateCard"
GetOrganizationInvitationOperation OperationName = "GetOrganizationInvitation"
GetOrganizationInvitationContactsOperation OperationName = "GetOrganizationInvitationContacts"
GetOrganizationNeedOperation OperationName = "GetOrganizationNeed"
GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog"
GrantMyConsentOperation OperationName = "GrantMyConsent"
HideOrganizationOperation OperationName = "HideOrganization"
ListMyAssessmentResultsOperation OperationName = "ListMyAssessmentResults"
ListMyCardAccessHistoryOperation OperationName = "ListMyCardAccessHistory"
ListMyConsentsOperation OperationName = "ListMyConsents"
ListMyHiddenOrganizationsOperation OperationName = "ListMyHiddenOrganizations"
ListMyInvitationsOperation OperationName = "ListMyInvitations"
ListMyOrganizationsOperation OperationName = "ListMyOrganizations"
ListMyPrivacyHistoryOperation OperationName = "ListMyPrivacyHistory"
ListMySupportCasesOperation OperationName = "ListMySupportCases"
ListOrganizationInvitationsOperation OperationName = "ListOrganizationInvitations"
ListOrganizationNeedsOperation OperationName = "ListOrganizationNeeds"
LoginOperation OperationName = "Login"
LogoutOperation OperationName = "Logout"
RaiseOrganizationInvitationSalaryOperation OperationName = "RaiseOrganizationInvitationSalary"
RecordMyAssessmentAttemptSignalsOperation OperationName = "RecordMyAssessmentAttemptSignals"
RegisterAccountOperation OperationName = "RegisterAccount"
RequestMyAccountDeletionOperation OperationName = "RequestMyAccountDeletion"
ResendEmailVerificationOperation OperationName = "ResendEmailVerification"
RevokeMyConsentOperation OperationName = "RevokeMyConsent"
RevokeMyOrganizationContactConsentOperation OperationName = "RevokeMyOrganizationContactConsent"
SaveMyProfileOperation OperationName = "SaveMyProfile"
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
SearchOrganizationMatchesOperation OperationName = "SearchOrganizationMatches"
SendOrganizationInvitationOperation OperationName = "SendOrganizationInvitation"
SetMyPublicationOperation OperationName = "SetMyPublication"
SetMySearchStatusOperation OperationName = "SetMySearchStatus"
StartMyAssessmentAttemptSessionOperation OperationName = "StartMyAssessmentAttemptSession"
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
UnhideOrganizationOperation OperationName = "UnhideOrganization"
UpdateOrganizationOperation OperationName = "UpdateOrganization"
UpdateOrganizationInvitationOperation OperationName = "UpdateOrganizationInvitation"
UpdateOrganizationNeedOperation OperationName = "UpdateOrganizationNeed"
ViewMyInvitationOperation OperationName = "ViewMyInvitation"
WithdrawOrganizationInvitationOperation OperationName = "WithdrawOrganizationInvitation"
)
@@ -2433,6 +2433,181 @@ func decodeHideOrganizationParams(args [1]string, argsEscaped bool, r *http.Requ
return params, nil
}
// ListMyAssessmentResultsParams is parameters of ListMyAssessmentResults operation.
type ListMyAssessmentResultsParams struct {
// Maximum number of results per page.
Limit OptInt32 `json:",omitempty,omitzero"`
// Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the
// first page. A malformed or foreign cursor returns 400 with code validation_failed.
Cursor OptString `json:",omitempty,omitzero"`
}
func unpackListMyAssessmentResultsParams(packed middleware.Parameters) (params ListMyAssessmentResultsParams) {
{
key := middleware.ParameterKey{
Name: "limit",
In: "query",
}
if v, ok := packed[key]; ok {
params.Limit = v.(OptInt32)
}
}
{
key := middleware.ParameterKey{
Name: "cursor",
In: "query",
}
if v, ok := packed[key]; ok {
params.Cursor = v.(OptString)
}
}
return params
}
func decodeListMyAssessmentResultsParams(args [0]string, argsEscaped bool, r *http.Request) (params ListMyAssessmentResultsParams, _ error) {
q := uri.NewQueryDecoder(r.URL.Query())
// Set default value for query: limit.
{
val := int32(20)
params.Limit.SetTo(val)
}
// Decode query: limit.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "limit",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotLimitVal int32
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToInt32(val)
if err != nil {
return err
}
paramsDotLimitVal = c
return nil
}(); err != nil {
return err
}
params.Limit.SetTo(paramsDotLimitVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.Limit.Get(); ok {
if err := func() error {
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 50,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(value)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "limit",
In: "query",
Err: err,
}
}
// Decode query: cursor.
if err := func() error {
cfg := uri.QueryParameterDecodingConfig{
Name: "cursor",
Style: uri.QueryStyleForm,
Explode: true,
}
if err := q.HasParam(cfg); err == nil {
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
var paramsDotCursorVal string
if err := func() error {
val, err := d.DecodeValue()
if err != nil {
return err
}
c, err := conv.ToString(val)
if err != nil {
return err
}
paramsDotCursorVal = c
return nil
}(); err != nil {
return err
}
params.Cursor.SetTo(paramsDotCursorVal)
return nil
}); err != nil {
return err
}
if err := func() error {
if value, ok := params.Cursor.Get(); ok {
if err := func() error {
if err := (validate.String{
MinLength: 1,
MinLengthSet: true,
MaxLength: 512,
MaxLengthSet: true,
Email: false,
Hostname: false,
Regex: regexMap["^[A-Za-z0-9_-]+$"],
MinNumeric: 0,
MinNumericSet: false,
MaxNumeric: 0,
MaxNumericSet: false,
}).Validate(string(value)); err != nil {
return errors.Wrap(err, "string")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
return params, &ogenerrors.DecodeParamError{
Name: "cursor",
In: "query",
Err: err,
}
}
return params, nil
}
// ListMyCardAccessHistoryParams is parameters of ListMyCardAccessHistory operation.
type ListMyCardAccessHistoryParams struct {
// Maximum number of items in the page. The server may return fewer items even when more remain; use
@@ -93,6 +93,85 @@ func (s *Server) decodeAcceptMyInvitationRequest(r *http.Request) (
}
}
func (s *Server) decodeAcknowledgeMyAssessmentSignalNoticeRequest(r *http.Request) (
req *AssessmentSignalNoticeAcknowledgement,
rawBody []byte,
close func() error,
rerr error,
) {
var closers []func() error
close = func() error {
var merr error
// Close in reverse order, to match defer behavior.
for i := len(closers) - 1; i >= 0; i-- {
c := closers[i]
merr = errors.Join(merr, c())
}
return merr
}
defer func() {
if rerr != nil {
rerr = errors.Join(rerr, close())
}
}()
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
if err != nil {
return req, rawBody, close, errors.Wrap(err, "parse media type")
}
switch {
case ct == "application/json":
if r.ContentLength == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
buf, err := io.ReadAll(r.Body)
defer func() {
_ = r.Body.Close()
}()
if err != nil {
return req, rawBody, close, err
}
// Reset the body to allow for downstream reading.
r.Body = io.NopCloser(bytes.NewBuffer(buf))
if len(buf) == 0 {
return req, rawBody, close, validate.ErrBodyRequired
}
rawBody = append(rawBody, buf...)
d := jx.DecodeBytes(buf)
var request AssessmentSignalNoticeAcknowledgement
if err := func() error {
if err := request.Decode(d); err != nil {
return err
}
if err := d.Skip(); err != io.EOF {
return errors.New("unexpected trailing data")
}
return nil
}(); err != nil {
err = &ogenerrors.DecodeBodyError{
ContentType: ct,
Body: buf,
Err: err,
}
return req, rawBody, close, err
}
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return req, rawBody, close, errors.Wrap(err, "validate")
}
return &request, rawBody, close, nil
default:
return req, rawBody, close, validate.InvalidContentType(ct)
}
}
func (s *Server) decodeCancelMyInvitationRequest(r *http.Request) (
req *InvitationCommand,
rawBody []byte,
@@ -165,6 +165,89 @@ func encodeAcceptMyInvitationResponse(response AcceptMyInvitationRes, w http.Res
}
}
func encodeAcknowledgeMyAssessmentSignalNoticeResponse(response AcknowledgeMyAssessmentSignalNoticeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentSignalNoticeHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(200)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *AcknowledgeMyAssessmentSignalNoticeBadRequest:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(400)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *AcknowledgeMyAssessmentSignalNoticeUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *AcknowledgeMyAssessmentSignalNoticeForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *AcknowledgeMyAssessmentSignalNoticeConflict:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(409)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeCancelMyInvitationResponse(response CancelMyInvitationRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *CandidateInvitationHeaders:
@@ -1683,6 +1766,65 @@ func encodeGetMyAssessmentResultResponse(response GetMyAssessmentResultRes, w ht
}
}
func encodeGetMyAssessmentSignalNoticeResponse(response GetMyAssessmentSignalNoticeRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentSignalNoticeHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(200)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *GetMyAssessmentSignalNoticeUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *GetMyAssessmentSignalNoticeForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeGetMyCardPreviewResponse(response GetMyCardPreviewRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *CardPreviewHeaders:
@@ -2790,6 +2932,77 @@ func encodeHideOrganizationResponse(response HideOrganizationRes, w http.Respons
}
}
func encodeListMyAssessmentResultsResponse(response ListMyAssessmentResultsRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *AssessmentResultHistoryPageHeaders:
w.Header().Set("Content-Type", "application/json; charset=utf-8")
// Encoding response headers.
{
h := uri.NewHeaderEncoder(w.Header())
// Encode "Cache-Control" header.
{
cfg := uri.HeaderParameterEncodingConfig{
Name: "Cache-Control",
Explode: false,
}
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
}); err != nil {
return errors.Wrap(err, "encode Cache-Control header")
}
}
}
w.WriteHeader(200)
e := new(jx.Encoder)
response.Response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ListMyAssessmentResultsBadRequest:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(400)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ListMyAssessmentResultsUnauthorized:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(401)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
case *ListMyAssessmentResultsForbidden:
w.Header().Set("Content-Type", "application/problem+json")
w.WriteHeader(403)
e := new(jx.Encoder)
response.Encode(e)
if _, err := e.WriteTo(w); err != nil {
return errors.Wrap(err, "write")
}
return nil
default:
return errors.Errorf("unexpected response type: %T", response)
}
}
func encodeListMyCardAccessHistoryResponse(response ListMyCardAccessHistoryRes, w http.ResponseWriter, span trace.Span) error {
switch response := response.(type) {
case *CardAccessListHeaders:
File diff suppressed because it is too large. Load diff
@@ -191,6 +191,22 @@ func (s *AccountScenario) UnmarshalText(data []byte) error {
}
}
type AcknowledgeMyAssessmentSignalNoticeBadRequest Problem
func (*AcknowledgeMyAssessmentSignalNoticeBadRequest) acknowledgeMyAssessmentSignalNoticeRes() {}
type AcknowledgeMyAssessmentSignalNoticeConflict Problem
func (*AcknowledgeMyAssessmentSignalNoticeConflict) acknowledgeMyAssessmentSignalNoticeRes() {}
type AcknowledgeMyAssessmentSignalNoticeForbidden Problem
func (*AcknowledgeMyAssessmentSignalNoticeForbidden) acknowledgeMyAssessmentSignalNoticeRes() {}
type AcknowledgeMyAssessmentSignalNoticeUnauthorized Problem
func (*AcknowledgeMyAssessmentSignalNoticeUnauthorized) acknowledgeMyAssessmentSignalNoticeRes() {}
// The anonymous candidate card as an organization reads it. Only explicitly published values reach it;
// unconfirmed stack suggestions and unknown values never do. Stack output uses a closed taxonomy. It
// carries no name, contact, resume text, employer, salary figure, account or profile identifier, and
@@ -1021,12 +1037,213 @@ func (s *AssessmentAvailabilityHeaders) SetResponse(val AssessmentAvailability)
func (*AssessmentAvailabilityHeaders) getMyAssessmentAvailabilityRes() {}
// Category decision captured when this result was stored. It is absent from legacy v1 results because
// their current grade cannot be inferred later. It never exposes review identifiers, private answers,
// or the candidate's current category after this decision.
// Ref: #/components/schemas/AssessmentCategoryDecisionView
type AssessmentCategoryDecisionView struct {
Status AssessmentCategoryDecisionViewStatus `json:"status"`
PreviousConfirmedGrade NilGradeCode `json:"previous_confirmed_grade"`
CurrentConfirmedGrade NilGradeCode `json:"current_confirmed_grade"`
Method NilAssessmentCategoryDecisionViewMethod `json:"method"`
Source NilAssessmentCategoryDecisionViewSource `json:"source"`
CalibrationStatus NilCalibrationStatus `json:"calibration_status"`
}
// GetStatus returns the value of Status.
func (s *AssessmentCategoryDecisionView) GetStatus() AssessmentCategoryDecisionViewStatus {
return s.Status
}
// GetPreviousConfirmedGrade returns the value of PreviousConfirmedGrade.
func (s *AssessmentCategoryDecisionView) GetPreviousConfirmedGrade() NilGradeCode {
return s.PreviousConfirmedGrade
}
// GetCurrentConfirmedGrade returns the value of CurrentConfirmedGrade.
func (s *AssessmentCategoryDecisionView) GetCurrentConfirmedGrade() NilGradeCode {
return s.CurrentConfirmedGrade
}
// GetMethod returns the value of Method.
func (s *AssessmentCategoryDecisionView) GetMethod() NilAssessmentCategoryDecisionViewMethod {
return s.Method
}
// GetSource returns the value of Source.
func (s *AssessmentCategoryDecisionView) GetSource() NilAssessmentCategoryDecisionViewSource {
return s.Source
}
// GetCalibrationStatus returns the value of CalibrationStatus.
func (s *AssessmentCategoryDecisionView) GetCalibrationStatus() NilCalibrationStatus {
return s.CalibrationStatus
}
// SetStatus sets the value of Status.
func (s *AssessmentCategoryDecisionView) SetStatus(val AssessmentCategoryDecisionViewStatus) {
s.Status = val
}
// SetPreviousConfirmedGrade sets the value of PreviousConfirmedGrade.
func (s *AssessmentCategoryDecisionView) SetPreviousConfirmedGrade(val NilGradeCode) {
s.PreviousConfirmedGrade = val
}
// SetCurrentConfirmedGrade sets the value of CurrentConfirmedGrade.
func (s *AssessmentCategoryDecisionView) SetCurrentConfirmedGrade(val NilGradeCode) {
s.CurrentConfirmedGrade = val
}
// SetMethod sets the value of Method.
func (s *AssessmentCategoryDecisionView) SetMethod(val NilAssessmentCategoryDecisionViewMethod) {
s.Method = val
}
// SetSource sets the value of Source.
func (s *AssessmentCategoryDecisionView) SetSource(val NilAssessmentCategoryDecisionViewSource) {
s.Source = val
}
// SetCalibrationStatus sets the value of CalibrationStatus.
func (s *AssessmentCategoryDecisionView) SetCalibrationStatus(val NilCalibrationStatus) {
s.CalibrationStatus = val
}
type AssessmentCategoryDecisionViewMethod string
const (
AssessmentCategoryDecisionViewMethodDemoBasicPassMark AssessmentCategoryDecisionViewMethod = "demo_basic_pass_mark"
)
// AllValues returns all AssessmentCategoryDecisionViewMethod values.
func (AssessmentCategoryDecisionViewMethod) AllValues() []AssessmentCategoryDecisionViewMethod {
return []AssessmentCategoryDecisionViewMethod{
AssessmentCategoryDecisionViewMethodDemoBasicPassMark,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentCategoryDecisionViewMethod) MarshalText() ([]byte, error) {
switch s {
case AssessmentCategoryDecisionViewMethodDemoBasicPassMark:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentCategoryDecisionViewMethod) UnmarshalText(data []byte) error {
switch AssessmentCategoryDecisionViewMethod(data) {
case AssessmentCategoryDecisionViewMethodDemoBasicPassMark:
*s = AssessmentCategoryDecisionViewMethodDemoBasicPassMark
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type AssessmentCategoryDecisionViewSource string
const (
AssessmentCategoryDecisionViewSourceSyntheticDemo AssessmentCategoryDecisionViewSource = "synthetic_demo"
)
// AllValues returns all AssessmentCategoryDecisionViewSource values.
func (AssessmentCategoryDecisionViewSource) AllValues() []AssessmentCategoryDecisionViewSource {
return []AssessmentCategoryDecisionViewSource{
AssessmentCategoryDecisionViewSourceSyntheticDemo,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentCategoryDecisionViewSource) MarshalText() ([]byte, error) {
switch s {
case AssessmentCategoryDecisionViewSourceSyntheticDemo:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentCategoryDecisionViewSource) UnmarshalText(data []byte) error {
switch AssessmentCategoryDecisionViewSource(data) {
case AssessmentCategoryDecisionViewSourceSyntheticDemo:
*s = AssessmentCategoryDecisionViewSourceSyntheticDemo
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
type AssessmentCategoryDecisionViewStatus string
const (
AssessmentCategoryDecisionViewStatusNotEligible AssessmentCategoryDecisionViewStatus = "not_eligible"
AssessmentCategoryDecisionViewStatusNotConfirmed AssessmentCategoryDecisionViewStatus = "not_confirmed"
AssessmentCategoryDecisionViewStatusAssigned AssessmentCategoryDecisionViewStatus = "assigned"
AssessmentCategoryDecisionViewStatusUnchanged AssessmentCategoryDecisionViewStatus = "unchanged"
)
// AllValues returns all AssessmentCategoryDecisionViewStatus values.
func (AssessmentCategoryDecisionViewStatus) AllValues() []AssessmentCategoryDecisionViewStatus {
return []AssessmentCategoryDecisionViewStatus{
AssessmentCategoryDecisionViewStatusNotEligible,
AssessmentCategoryDecisionViewStatusNotConfirmed,
AssessmentCategoryDecisionViewStatusAssigned,
AssessmentCategoryDecisionViewStatusUnchanged,
}
}
// MarshalText implements encoding.TextMarshaler.
func (s AssessmentCategoryDecisionViewStatus) MarshalText() ([]byte, error) {
switch s {
case AssessmentCategoryDecisionViewStatusNotEligible:
return []byte(s), nil
case AssessmentCategoryDecisionViewStatusNotConfirmed:
return []byte(s), nil
case AssessmentCategoryDecisionViewStatusAssigned:
return []byte(s), nil
case AssessmentCategoryDecisionViewStatusUnchanged:
return []byte(s), nil
default:
return nil, errors.Errorf("invalid value: %q", s)
}
}
// UnmarshalText implements encoding.TextUnmarshaler.
func (s *AssessmentCategoryDecisionViewStatus) UnmarshalText(data []byte) error {
switch AssessmentCategoryDecisionViewStatus(data) {
case AssessmentCategoryDecisionViewStatusNotEligible:
*s = AssessmentCategoryDecisionViewStatusNotEligible
return nil
case AssessmentCategoryDecisionViewStatusNotConfirmed:
*s = AssessmentCategoryDecisionViewStatusNotConfirmed
return nil
case AssessmentCategoryDecisionViewStatusAssigned:
*s = AssessmentCategoryDecisionViewStatusAssigned
return nil
case AssessmentCategoryDecisionViewStatusUnchanged:
*s = AssessmentCategoryDecisionViewStatusUnchanged
return nil
default:
return errors.Errorf("invalid value: %q", data)
}
}
// Ref: #/components/schemas/AssessmentClipboardSignal
type AssessmentClipboardSignal struct {
Kind AssessmentClipboardSignalKind `json:"kind"`
ItemInstanceID AssessmentItemId `json:"item_instance_id"`
OccurredAt Timestamp `json:"occurred_at"`
// Byte count only. Clipboard or selection contents are not transmitted or retained.
// Size only; clipboard and selection contents are never transmitted or retained. For `paste` it is the
// UTF-8 byte count of the pasted plain text plus the byte size of pasted files, counted on the device
// from the paste event. For `copy` and `cut` it is the selection length in UTF-16 code units taken
// from the selection offsets of a form field, or zero when the field offsets are unavailable; it is an
// approximate size and the selected text is not read. The server applies no conversion and treats the
// value as an order-of-magnitude indicator.
SizeBytes int32 `json:"size_bytes"`
}
@@ -1538,7 +1755,8 @@ type AssessmentCorrectiveResult struct {
ConfirmedGrade NilGradeCode `json:"confirmed_grade"`
// Confirmed grade of the specialization before this attempt, or null. When the attempt confirmed
// nothing, this grade stays in force.
PreviousConfirmedGrade NilGradeCode `json:"previous_confirmed_grade"`
PreviousConfirmedGrade NilGradeCode `json:"previous_confirmed_grade"`
CategoryDecision OptAssessmentCategoryDecisionView `json:"category_decision"`
// Strength of an adaptive confirmation, otherwise null.
Strength NilAssessmentStrength `json:"strength"`
CalibrationStatus CalibrationStatus `json:"calibration_status"`
@@ -1622,6 +1840,11 @@ func (s *AssessmentCorrectiveResult) GetPreviousConfirmedGrade() NilGradeCode {
return s.PreviousConfirmedGrade
}
// GetCategoryDecision returns the value of CategoryDecision.
func (s *AssessmentCorrectiveResult) GetCategoryDecision() OptAssessmentCategoryDecisionView {
return s.CategoryDecision
}
// GetStrength returns the value of Strength.
func (s *AssessmentCorrectiveResult) GetStrength() NilAssessmentStrength {
return s.Strength
@@ -1737,6 +1960,11 @@ func (s *AssessmentCorrectiveResult) SetPreviousConfirmedGrade(val NilGradeCode)
s.PreviousConfirmedGrade = val
}
// SetCategoryDecision sets the value of CategoryDecision.
func (s *AssessmentCorrectiveResult) SetCategoryDecision(val OptAssessmentCategoryDecisionView) {
s.CategoryDecision = val
}
// SetStrength sets the value of Strength.
func (s *AssessmentCorrectiveResult) SetStrength(val NilAssessmentStrength) {
s.Strength = val
@@ -4131,7 +4359,8 @@ type AssessmentQualifiedResult struct {
ConfirmedGrade NilGradeCode `json:"confirmed_grade"`
// Confirmed grade of the specialization before this attempt, or null. When the attempt confirmed
// nothing, this grade stays in force.
PreviousConfirmedGrade NilGradeCode `json:"previous_confirmed_grade"`
PreviousConfirmedGrade NilGradeCode `json:"previous_confirmed_grade"`
CategoryDecision OptAssessmentCategoryDecisionView `json:"category_decision"`
// Strength of an adaptive confirmation, otherwise null.
Strength NilAssessmentStrength `json:"strength"`
CalibrationStatus CalibrationStatus `json:"calibration_status"`
@@ -4215,6 +4444,11 @@ func (s *AssessmentQualifiedResult) GetPreviousConfirmedGrade() NilGradeCode {
return s.PreviousConfirmedGrade
}
// GetCategoryDecision returns the value of CategoryDecision.
func (s *AssessmentQualifiedResult) GetCategoryDecision() OptAssessmentCategoryDecisionView {
return s.CategoryDecision
}
// GetStrength returns the value of Strength.
func (s *AssessmentQualifiedResult) GetStrength() NilAssessmentStrength {
return s.Strength
@@ -4330,6 +4564,11 @@ func (s *AssessmentQualifiedResult) SetPreviousConfirmedGrade(val NilGradeCode)
s.PreviousConfirmedGrade = val
}
// SetCategoryDecision sets the value of CategoryDecision.
func (s *AssessmentQualifiedResult) SetCategoryDecision(val OptAssessmentCategoryDecisionView) {
s.CategoryDecision = val
}
// SetStrength sets the value of Strength.
func (s *AssessmentQualifiedResult) SetStrength(val NilAssessmentStrength) {
s.Strength = val
@@ -4499,6 +4738,78 @@ func (s *AssessmentRealMode) UnmarshalText(data []byte) error {
}
}
// A completed root or corrective result. Training-only demo_express results are excluded from
// qualification history.
// Ref: #/components/schemas/AssessmentRealResult
// AssessmentRealResult represents sum type.
type AssessmentRealResult struct {
// Type selects the active sum variant, switch on this field.
Type AssessmentRealResultType
AssessmentQualifiedResult AssessmentQualifiedResult
AssessmentCorrectiveResult AssessmentCorrectiveResult
}
// AssessmentRealResultType is oneOf type of AssessmentRealResult.
type AssessmentRealResultType string
// Possible values for AssessmentRealResultType.
const (
AssessmentQualifiedResultAssessmentRealResult AssessmentRealResultType = "root"
AssessmentCorrectiveResultAssessmentRealResult AssessmentRealResultType = "corrective"
)
// IsAssessmentQualifiedResult reports whether AssessmentRealResult is AssessmentQualifiedResult.
func (s AssessmentRealResult) IsAssessmentQualifiedResult() bool {
return s.Type == AssessmentQualifiedResultAssessmentRealResult
}
// IsAssessmentCorrectiveResult reports whether AssessmentRealResult is AssessmentCorrectiveResult.
func (s AssessmentRealResult) IsAssessmentCorrectiveResult() bool {
return s.Type == AssessmentCorrectiveResultAssessmentRealResult
}
// SetAssessmentQualifiedResult sets AssessmentRealResult to AssessmentQualifiedResult.
func (s *AssessmentRealResult) SetAssessmentQualifiedResult(v AssessmentQualifiedResult) {
s.Type = AssessmentQualifiedResultAssessmentRealResult
s.AssessmentQualifiedResult = v
}
// GetAssessmentQualifiedResult returns AssessmentQualifiedResult and true boolean if AssessmentRealResult is AssessmentQualifiedResult.
func (s AssessmentRealResult) GetAssessmentQualifiedResult() (v AssessmentQualifiedResult, ok bool) {
if !s.IsAssessmentQualifiedResult() {
return v, false
}
return s.AssessmentQualifiedResult, true
}
// NewAssessmentQualifiedResultAssessmentRealResult returns new AssessmentRealResult from AssessmentQualifiedResult.
func NewAssessmentQualifiedResultAssessmentRealResult(v AssessmentQualifiedResult) AssessmentRealResult {
var s AssessmentRealResult
s.SetAssessmentQualifiedResult(v)
return s
}
// SetAssessmentCorrectiveResult sets AssessmentRealResult to AssessmentCorrectiveResult.
func (s *AssessmentRealResult) SetAssessmentCorrectiveResult(v AssessmentCorrectiveResult) {
s.Type = AssessmentCorrectiveResultAssessmentRealResult
s.AssessmentCorrectiveResult = v
}
// GetAssessmentCorrectiveResult returns AssessmentCorrectiveResult and true boolean if AssessmentRealResult is AssessmentCorrectiveResult.
func (s AssessmentRealResult) GetAssessmentCorrectiveResult() (v AssessmentCorrectiveResult, ok bool) {
if !s.IsAssessmentCorrectiveResult() {
return v, false
}
return s.AssessmentCorrectiveResult, true
}
// NewAssessmentCorrectiveResultAssessmentRealResult returns new AssessmentRealResult from AssessmentCorrectiveResult.
func NewAssessmentCorrectiveResultAssessmentRealResult(v AssessmentCorrectiveResult) AssessmentRealResult {
var s AssessmentRealResult
s.SetAssessmentCorrectiveResult(v)
return s
}
// Immutable result of a terminal assessment attempt. The result shape distinguishes real grade
// decisions from demo_express training output.
// Ref: #/components/schemas/AssessmentResult
@@ -4627,6 +4938,62 @@ func (s *AssessmentResultHeaders) SetResponse(val AssessmentResult) {
func (*AssessmentResultHeaders) getMyAssessmentResultRes() {}
// Owner-only immutable root and corrective results ordered by decided_at and attempt_id descending.
// Legacy v1 results omit category_decision.
// Ref: #/components/schemas/AssessmentResultHistoryPage
type AssessmentResultHistoryPage struct {
Items []AssessmentRealResult `json:"items"`
Page PageInfo `json:"page"`
}
// GetItems returns the value of Items.
func (s *AssessmentResultHistoryPage) GetItems() []AssessmentRealResult {
return s.Items
}
// GetPage returns the value of Page.
func (s *AssessmentResultHistoryPage) GetPage() PageInfo {
return s.Page
}
// SetItems sets the value of Items.
func (s *AssessmentResultHistoryPage) SetItems(val []AssessmentRealResult) {
s.Items = val
}
// SetPage sets the value of Page.
func (s *AssessmentResultHistoryPage) SetPage(val PageInfo) {
s.Page = val
}
// AssessmentResultHistoryPageHeaders wraps AssessmentResultHistoryPage with response headers.
type AssessmentResultHistoryPageHeaders struct {
CacheControl CacheControlNoStore
Response AssessmentResultHistoryPage
}
// GetCacheControl returns the value of CacheControl.
func (s *AssessmentResultHistoryPageHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *AssessmentResultHistoryPageHeaders) GetResponse() AssessmentResultHistoryPage {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *AssessmentResultHistoryPageHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *AssessmentResultHistoryPageHeaders) SetResponse(val AssessmentResultHistoryPage) {
s.Response = val
}
func (*AssessmentResultHistoryPageHeaders) listMyAssessmentResultsRes() {}
// Work sessions of the attempt, as the policy version limits them, for example two sessions within the
// time limit.
//
@@ -4817,6 +5184,97 @@ func NewAssessmentFullscreenExitSignalAssessmentSignalEvent(v AssessmentFullscre
return s
}
// State of the notice about the signals that are collected during a real assessment attempt. The
// acknowledgement is a record that the candidate was informed. It is not a consent, grants no purpose,
// and neither enables nor blocks signal storage; C3 remains the only consent that the signal operation
// checks.
// Ref: #/components/schemas/AssessmentSignalNotice
type AssessmentSignalNotice struct {
// The version the server currently requires the candidate to acknowledge.
NoticeVersion AssessmentSignalNoticeVersion `json:"notice_version"`
// True when the candidate acknowledged `notice_version`.
Acknowledged bool `json:"acknowledged"`
// Server time of the first acknowledgement of this version, or null.
AcknowledgedAt NilTimestamp `json:"acknowledged_at"`
}
// GetNoticeVersion returns the value of NoticeVersion.
func (s *AssessmentSignalNotice) GetNoticeVersion() AssessmentSignalNoticeVersion {
return s.NoticeVersion
}
// GetAcknowledged returns the value of Acknowledged.
func (s *AssessmentSignalNotice) GetAcknowledged() bool {
return s.Acknowledged
}
// GetAcknowledgedAt returns the value of AcknowledgedAt.
func (s *AssessmentSignalNotice) GetAcknowledgedAt() NilTimestamp {
return s.AcknowledgedAt
}
// SetNoticeVersion sets the value of NoticeVersion.
func (s *AssessmentSignalNotice) SetNoticeVersion(val AssessmentSignalNoticeVersion) {
s.NoticeVersion = val
}
// SetAcknowledged sets the value of Acknowledged.
func (s *AssessmentSignalNotice) SetAcknowledged(val bool) {
s.Acknowledged = val
}
// SetAcknowledgedAt sets the value of AcknowledgedAt.
func (s *AssessmentSignalNotice) SetAcknowledgedAt(val NilTimestamp) {
s.AcknowledgedAt = val
}
// The notice version the candidate was shown and acknowledged.
// Ref: #/components/schemas/AssessmentSignalNoticeAcknowledgement
type AssessmentSignalNoticeAcknowledgement struct {
NoticeVersion AssessmentSignalNoticeVersion `json:"notice_version"`
}
// GetNoticeVersion returns the value of NoticeVersion.
func (s *AssessmentSignalNoticeAcknowledgement) GetNoticeVersion() AssessmentSignalNoticeVersion {
return s.NoticeVersion
}
// SetNoticeVersion sets the value of NoticeVersion.
func (s *AssessmentSignalNoticeAcknowledgement) SetNoticeVersion(val AssessmentSignalNoticeVersion) {
s.NoticeVersion = val
}
// AssessmentSignalNoticeHeaders wraps AssessmentSignalNotice with response headers.
type AssessmentSignalNoticeHeaders struct {
CacheControl CacheControlNoStore
Response AssessmentSignalNotice
}
// GetCacheControl returns the value of CacheControl.
func (s *AssessmentSignalNoticeHeaders) GetCacheControl() CacheControlNoStore {
return s.CacheControl
}
// GetResponse returns the value of Response.
func (s *AssessmentSignalNoticeHeaders) GetResponse() AssessmentSignalNotice {
return s.Response
}
// SetCacheControl sets the value of CacheControl.
func (s *AssessmentSignalNoticeHeaders) SetCacheControl(val CacheControlNoStore) {
s.CacheControl = val
}
// SetResponse sets the value of Response.
func (s *AssessmentSignalNoticeHeaders) SetResponse(val AssessmentSignalNotice) {
s.Response = val
}
func (*AssessmentSignalNoticeHeaders) acknowledgeMyAssessmentSignalNoticeRes() {}
func (*AssessmentSignalNoticeHeaders) getMyAssessmentSignalNoticeRes() {}
type AssessmentSignalNoticeVersion int32
// Receipt for the submitted batch. It contains no signal details, score, review decision, threshold,
// or result band.
// Ref: #/components/schemas/AssessmentSignalReceipt
@@ -9452,6 +9910,14 @@ type GetMyAssessmentResultUnauthorized Problem
func (*GetMyAssessmentResultUnauthorized) getMyAssessmentResultRes() {}
type GetMyAssessmentSignalNoticeForbidden Problem
func (*GetMyAssessmentSignalNoticeForbidden) getMyAssessmentSignalNoticeRes() {}
type GetMyAssessmentSignalNoticeUnauthorized Problem
func (*GetMyAssessmentSignalNoticeUnauthorized) getMyAssessmentSignalNoticeRes() {}
type GetMyCardPreviewForbidden Problem
func (*GetMyCardPreviewForbidden) getMyCardPreviewRes() {}
@@ -11413,6 +11879,18 @@ func NewPracticeItemContentItemContent(v PracticeItemContent) ItemContent {
return s
}
type ListMyAssessmentResultsBadRequest Problem
func (*ListMyAssessmentResultsBadRequest) listMyAssessmentResultsRes() {}
type ListMyAssessmentResultsForbidden Problem
func (*ListMyAssessmentResultsForbidden) listMyAssessmentResultsRes() {}
type ListMyAssessmentResultsUnauthorized Problem
func (*ListMyAssessmentResultsUnauthorized) listMyAssessmentResultsRes() {}
type ListMyCardAccessHistoryBadRequest Problem
func (*ListMyCardAccessHistoryBadRequest) listMyCardAccessHistoryRes() {}
@@ -15727,6 +16205,96 @@ func (o NilAnonymousCardContent) Or(d AnonymousCardContent) AnonymousCardContent
return d
}
// NewNilAssessmentCategoryDecisionViewMethod returns new NilAssessmentCategoryDecisionViewMethod with value set to v.
func NewNilAssessmentCategoryDecisionViewMethod(v AssessmentCategoryDecisionViewMethod) NilAssessmentCategoryDecisionViewMethod {
return NilAssessmentCategoryDecisionViewMethod{
Value: v,
}
}
// NilAssessmentCategoryDecisionViewMethod is nullable AssessmentCategoryDecisionViewMethod.
type NilAssessmentCategoryDecisionViewMethod struct {
Value AssessmentCategoryDecisionViewMethod
Null bool
}
// SetTo sets value to v.
func (o *NilAssessmentCategoryDecisionViewMethod) SetTo(v AssessmentCategoryDecisionViewMethod) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilAssessmentCategoryDecisionViewMethod) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilAssessmentCategoryDecisionViewMethod) SetToNull() {
o.Null = true
var v AssessmentCategoryDecisionViewMethod
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilAssessmentCategoryDecisionViewMethod) Get() (v AssessmentCategoryDecisionViewMethod, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilAssessmentCategoryDecisionViewMethod) Or(d AssessmentCategoryDecisionViewMethod) AssessmentCategoryDecisionViewMethod {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilAssessmentCategoryDecisionViewSource returns new NilAssessmentCategoryDecisionViewSource with value set to v.
func NewNilAssessmentCategoryDecisionViewSource(v AssessmentCategoryDecisionViewSource) NilAssessmentCategoryDecisionViewSource {
return NilAssessmentCategoryDecisionViewSource{
Value: v,
}
}
// NilAssessmentCategoryDecisionViewSource is nullable AssessmentCategoryDecisionViewSource.
type NilAssessmentCategoryDecisionViewSource struct {
Value AssessmentCategoryDecisionViewSource
Null bool
}
// SetTo sets value to v.
func (o *NilAssessmentCategoryDecisionViewSource) SetTo(v AssessmentCategoryDecisionViewSource) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilAssessmentCategoryDecisionViewSource) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilAssessmentCategoryDecisionViewSource) SetToNull() {
o.Null = true
var v AssessmentCategoryDecisionViewSource
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilAssessmentCategoryDecisionViewSource) Get() (v AssessmentCategoryDecisionViewSource, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilAssessmentCategoryDecisionViewSource) Or(d AssessmentCategoryDecisionViewSource) AssessmentCategoryDecisionViewSource {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilAssessmentItem returns new NilAssessmentItem with value set to v.
func NewNilAssessmentItem(v AssessmentItem) NilAssessmentItem {
return NilAssessmentItem{
@@ -16087,6 +16655,51 @@ func (o NilBool) Or(d bool) bool {
return d
}
// NewNilCalibrationStatus returns new NilCalibrationStatus with value set to v.
func NewNilCalibrationStatus(v CalibrationStatus) NilCalibrationStatus {
return NilCalibrationStatus{
Value: v,
}
}
// NilCalibrationStatus is nullable CalibrationStatus.
type NilCalibrationStatus struct {
Value CalibrationStatus
Null bool
}
// SetTo sets value to v.
func (o *NilCalibrationStatus) SetTo(v CalibrationStatus) {
o.Null = false
o.Value = v
}
// IsNull returns true if value is Null.
func (o NilCalibrationStatus) IsNull() bool { return o.Null }
// SetToNull sets value to null.
func (o *NilCalibrationStatus) SetToNull() {
o.Null = true
var v CalibrationStatus
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o NilCalibrationStatus) Get() (v CalibrationStatus, ok bool) {
if o.Null {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o NilCalibrationStatus) Or(d CalibrationStatus) CalibrationStatus {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewNilCandidateExperience returns new NilCandidateExperience with value set to v.
func NewNilCandidateExperience(v CandidateExperience) NilCandidateExperience {
return NilCandidateExperience{
@@ -19356,6 +19969,52 @@ func (s *OnboardingStep) UnmarshalText(data []byte) error {
}
}
// NewOptAssessmentCategoryDecisionView returns new OptAssessmentCategoryDecisionView with value set to v.
func NewOptAssessmentCategoryDecisionView(v AssessmentCategoryDecisionView) OptAssessmentCategoryDecisionView {
return OptAssessmentCategoryDecisionView{
Value: v,
Set: true,
}
}
// OptAssessmentCategoryDecisionView is optional AssessmentCategoryDecisionView.
type OptAssessmentCategoryDecisionView struct {
Value AssessmentCategoryDecisionView
Set bool
}
// IsSet returns true if OptAssessmentCategoryDecisionView was set.
func (o OptAssessmentCategoryDecisionView) IsSet() bool { return o.Set }
// Reset unsets value.
func (o *OptAssessmentCategoryDecisionView) Reset() {
var v AssessmentCategoryDecisionView
o.Value = v
o.Set = false
}
// SetTo sets value to v.
func (o *OptAssessmentCategoryDecisionView) SetTo(v AssessmentCategoryDecisionView) {
o.Set = true
o.Value = v
}
// Get returns value and boolean that denotes whether value was set.
func (o OptAssessmentCategoryDecisionView) Get() (v AssessmentCategoryDecisionView, ok bool) {
if !o.Set {
return v, false
}
return o.Value, true
}
// Or returns value if set, or given parameter if does not.
func (o OptAssessmentCategoryDecisionView) Or(d AssessmentCategoryDecisionView) AssessmentCategoryDecisionView {
if v, ok := o.Get(); ok {
return v
}
return d
}
// NewOptCandidateSalaryCompatibility returns new OptCandidateSalaryCompatibility with value set to v.
func NewOptCandidateSalaryCompatibility(v CandidateSalaryCompatibility) OptCandidateSalaryCompatibility {
return OptCandidateSalaryCompatibility{
@@ -56,63 +56,66 @@ func findAuthorization(h http.Header, prefix string) (string, bool) {
// operationRolesSessionCookie is a private map storing roles per operation.
var operationRolesSessionCookie = map[string][]string{
AcceptMyInvitationOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
CreateOrganizationNeedOperation: []string{},
DeclineMyInvitationOperation: []string{},
FinalizeMyAssessmentAttemptOperation: []string{},
GetCurrentAccountOperation: []string{},
GetCurrentSessionOperation: []string{},
GetMyAssessmentAttemptOperation: []string{},
GetMyAssessmentAvailabilityOperation: []string{},
GetMyAssessmentResultOperation: []string{},
GetMyCardPreviewOperation: []string{},
GetMyConsentTextOperation: []string{},
GetMyInvitationOperation: []string{},
GetMyPrivacySettingsOperation: []string{},
GetMyProfileOperation: []string{},
GetMyQuestionnaireOperation: []string{},
GetMySupportCaseOperation: []string{},
GetOrganizationOperation: []string{},
GetOrganizationCandidateCardOperation: []string{},
GetOrganizationInvitationOperation: []string{},
GetOrganizationInvitationContactsOperation: []string{},
GetOrganizationNeedOperation: []string{},
GrantMyConsentOperation: []string{},
HideOrganizationOperation: []string{},
ListMyCardAccessHistoryOperation: []string{},
ListMyConsentsOperation: []string{},
ListMyHiddenOrganizationsOperation: []string{},
ListMyInvitationsOperation: []string{},
ListMyOrganizationsOperation: []string{},
ListMyPrivacyHistoryOperation: []string{},
ListMySupportCasesOperation: []string{},
ListOrganizationInvitationsOperation: []string{},
ListOrganizationNeedsOperation: []string{},
LogoutOperation: []string{},
RaiseOrganizationInvitationSalaryOperation: []string{},
RecordMyAssessmentAttemptSignalsOperation: []string{},
RequestMyAccountDeletionOperation: []string{},
RevokeMyConsentOperation: []string{},
RevokeMyOrganizationContactConsentOperation: []string{},
SaveMyProfileOperation: []string{},
SaveMyQuestionnaireOperation: []string{},
SearchOrganizationMatchesOperation: []string{},
SendOrganizationInvitationOperation: []string{},
SetMyPublicationOperation: []string{},
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
UpdateOrganizationNeedOperation: []string{},
ViewMyInvitationOperation: []string{},
WithdrawOrganizationInvitationOperation: []string{},
AcceptMyInvitationOperation: []string{},
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
CreateOrganizationNeedOperation: []string{},
DeclineMyInvitationOperation: []string{},
FinalizeMyAssessmentAttemptOperation: []string{},
GetCurrentAccountOperation: []string{},
GetCurrentSessionOperation: []string{},
GetMyAssessmentAttemptOperation: []string{},
GetMyAssessmentAvailabilityOperation: []string{},
GetMyAssessmentResultOperation: []string{},
GetMyAssessmentSignalNoticeOperation: []string{},
GetMyCardPreviewOperation: []string{},
GetMyConsentTextOperation: []string{},
GetMyInvitationOperation: []string{},
GetMyPrivacySettingsOperation: []string{},
GetMyProfileOperation: []string{},
GetMyQuestionnaireOperation: []string{},
GetMySupportCaseOperation: []string{},
GetOrganizationOperation: []string{},
GetOrganizationCandidateCardOperation: []string{},
GetOrganizationInvitationOperation: []string{},
GetOrganizationInvitationContactsOperation: []string{},
GetOrganizationNeedOperation: []string{},
GrantMyConsentOperation: []string{},
HideOrganizationOperation: []string{},
ListMyAssessmentResultsOperation: []string{},
ListMyCardAccessHistoryOperation: []string{},
ListMyConsentsOperation: []string{},
ListMyHiddenOrganizationsOperation: []string{},
ListMyInvitationsOperation: []string{},
ListMyOrganizationsOperation: []string{},
ListMyPrivacyHistoryOperation: []string{},
ListMySupportCasesOperation: []string{},
ListOrganizationInvitationsOperation: []string{},
ListOrganizationNeedsOperation: []string{},
LogoutOperation: []string{},
RaiseOrganizationInvitationSalaryOperation: []string{},
RecordMyAssessmentAttemptSignalsOperation: []string{},
RequestMyAccountDeletionOperation: []string{},
RevokeMyConsentOperation: []string{},
RevokeMyOrganizationContactConsentOperation: []string{},
SaveMyProfileOperation: []string{},
SaveMyQuestionnaireOperation: []string{},
SearchOrganizationMatchesOperation: []string{},
SendOrganizationInvitationOperation: []string{},
SetMyPublicationOperation: []string{},
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
UpdateOrganizationNeedOperation: []string{},
ViewMyInvitationOperation: []string{},
WithdrawOrganizationInvitationOperation: []string{},
}
// GetRolesForSessionCookie returns the required roles for the given operation.
@@ -138,37 +141,38 @@ func GetRolesForSessionCookie(operation string) []string {
// operationRolesSessionCsrf is a private map storing roles per operation.
var operationRolesSessionCsrf = map[string][]string{
AcceptMyInvitationOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
CreateOrganizationNeedOperation: []string{},
DeclineMyInvitationOperation: []string{},
FinalizeMyAssessmentAttemptOperation: []string{},
GrantMyConsentOperation: []string{},
HideOrganizationOperation: []string{},
LogoutOperation: []string{},
RaiseOrganizationInvitationSalaryOperation: []string{},
RecordMyAssessmentAttemptSignalsOperation: []string{},
RequestMyAccountDeletionOperation: []string{},
RevokeMyConsentOperation: []string{},
RevokeMyOrganizationContactConsentOperation: []string{},
SaveMyProfileOperation: []string{},
SaveMyQuestionnaireOperation: []string{},
SearchOrganizationMatchesOperation: []string{},
SendOrganizationInvitationOperation: []string{},
SetMyPublicationOperation: []string{},
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
UpdateOrganizationNeedOperation: []string{},
ViewMyInvitationOperation: []string{},
WithdrawOrganizationInvitationOperation: []string{},
AcceptMyInvitationOperation: []string{},
AcknowledgeMyAssessmentSignalNoticeOperation: []string{},
CancelMyInvitationOperation: []string{},
CreateMyAssessmentAttemptOperation: []string{},
CreateMySupportCaseOperation: []string{},
CreateOrganizationOperation: []string{},
CreateOrganizationInvitationOperation: []string{},
CreateOrganizationNeedOperation: []string{},
DeclineMyInvitationOperation: []string{},
FinalizeMyAssessmentAttemptOperation: []string{},
GrantMyConsentOperation: []string{},
HideOrganizationOperation: []string{},
LogoutOperation: []string{},
RaiseOrganizationInvitationSalaryOperation: []string{},
RecordMyAssessmentAttemptSignalsOperation: []string{},
RequestMyAccountDeletionOperation: []string{},
RevokeMyConsentOperation: []string{},
RevokeMyOrganizationContactConsentOperation: []string{},
SaveMyProfileOperation: []string{},
SaveMyQuestionnaireOperation: []string{},
SearchOrganizationMatchesOperation: []string{},
SendOrganizationInvitationOperation: []string{},
SetMyPublicationOperation: []string{},
SetMySearchStatusOperation: []string{},
StartMyAssessmentAttemptSessionOperation: []string{},
SubmitMyAssessmentAnswerOperation: []string{},
UnhideOrganizationOperation: []string{},
UpdateOrganizationOperation: []string{},
UpdateOrganizationInvitationOperation: []string{},
UpdateOrganizationNeedOperation: []string{},
ViewMyInvitationOperation: []string{},
WithdrawOrganizationInvitationOperation: []string{},
}
// GetRolesForSessionCsrf returns the required roles for the given operation.
@@ -64,6 +64,27 @@ type Handler interface {
//
// POST /api/v1/me/invitations/{invitation_id}/accept
AcceptMyInvitation(ctx context.Context, req *InvitationAcceptance, params AcceptMyInvitationParams) (AcceptMyInvitationRes, error)
// AcknowledgeMyAssessmentSignalNotice implements AcknowledgeMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email, the CSRF token of that
// session in X-CSRF-Token, and an allowed Origin. The body carries the notice version the candidate
// was shown. The server stores the acknowledgement for the account and that version; the response
// carries the server time of the first acknowledgement.
//
// The operation needs no Idempotency-Key: it is idempotent. Repeating it for an acknowledged version
// changes nothing, keeps the first time, and answers 200, so a retry after a lost response succeeds. A
// version other than the one the server requires answers 409 state_conflict and stores nothing; the
// client reads the notice again.
//
// The acknowledgement is not a consent. It does not grant, replace, or hide C3, and it does not affect
// the signal operation or any score, category, or quota. The body carries no signal, answer, or
// clipboard data.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account (403 forbidden), then the version (409).
//
// PUT /api/v1/me/assessment-signal-notice
AcknowledgeMyAssessmentSignalNotice(ctx context.Context, req *AssessmentSignalNoticeAcknowledgement) (AcknowledgeMyAssessmentSignalNoticeRes, error)
// CancelMyInvitation implements CancelMyInvitation operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -599,6 +620,30 @@ type Handler interface {
//
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (GetMyAssessmentResultRes, error)
// GetMyAssessmentSignalNotice implements GetMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email; the candidate comes from
// the session. Returns the notice version that the server requires now and whether this candidate
// acknowledged it. The notice lists the signals that are collected during a real assessment attempt
// and states that images, sound, and clipboard contents are not collected. Client signals are the time
// away from the tab or window, copy, paste and cut with a size only, and exits from fullscreen mode.
// Server signals are the response time of each item measured by the server, a change of network
// address during the attempt, parallel sessions, and the comparison of answers to variants of the same
// task by candidates. The server stores for these only one-way keyed digests: it stores no network
// address, no session token, and no answer text. Client signals are stored only while the C3 consent
// is current. The client shows it before a real attempt starts and does not start the attempt until
// the notice is acknowledged.
//
// The acknowledgement is stored on the server per account and notice version, so it survives a reload
// and a new browser. It is not a consent and never changes C3: the signal operation still requires a
// current C3 consent, and an unacknowledged notice does not make that operation fail. The demo_express
// training mode collects no signals and needs no acknowledgement.
//
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account or
// an unconfirmed email answers 403 forbidden.
//
// GET /api/v1/me/assessment-signal-notice
GetMyAssessmentSignalNotice(ctx context.Context) (GetMyAssessmentSignalNoticeRes, error)
// GetMyCardPreview implements GetMyCardPreview operation.
//
// Requires the session cookie of a candidate account. Returns a private preview of the permitted
@@ -956,6 +1001,21 @@ type Handler interface {
//
// PUT /api/v1/me/privacy/hidden-organizations/{org_id}
HideOrganization(ctx context.Context, params HideOrganizationParams) (HideOrganizationRes, error)
// ListMyAssessmentResults implements ListMyAssessmentResults operation.
//
// Requires a candidate session. Returns only completed root and corrective results owned by this
// candidate, newest first by decided_at and attempt_id. demo_express training results never appear.
// The cursor is opaque and bound to this candidate and listing; a malformed or foreign cursor returns
// 400 validation_failed.
//
// A v2 result includes the category decision captured when that attempt ended, including the confirmed
// grade then in force. Legacy v1 results omit category_decision because a later category must not be
// projected backward. Later policy, bank, review, or category changes do not alter either result.
// Employers cannot read this history; their separate projection contains only the current permitted
// category and no answers.
//
// GET /api/v1/me/assessment-results
ListMyAssessmentResults(ctx context.Context, params ListMyAssessmentResultsParams) (ListMyAssessmentResultsRes, error)
// ListMyCardAccessHistory implements ListMyCardAccessHistory operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
@@ -72,6 +72,30 @@ func (UnimplementedHandler) AcceptMyInvitation(ctx context.Context, req *Invitat
return r, ht.ErrNotImplemented
}
// AcknowledgeMyAssessmentSignalNotice implements AcknowledgeMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email, the CSRF token of that
// session in X-CSRF-Token, and an allowed Origin. The body carries the notice version the candidate
// was shown. The server stores the acknowledgement for the account and that version; the response
// carries the server time of the first acknowledgement.
//
// The operation needs no Idempotency-Key: it is idempotent. Repeating it for an acknowledged version
// changes nothing, keeps the first time, and answers 200, so a retry after a lost response succeeds. A
// version other than the one the server requires answers 409 state_conflict and stores nothing; the
// client reads the notice again.
//
// The acknowledgement is not a consent. It does not grant, replace, or hide C3, and it does not affect
// the signal operation or any score, category, or quota. The body carries no signal, answer, or
// clipboard data.
//
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
// account (403 forbidden), then the version (409).
//
// PUT /api/v1/me/assessment-signal-notice
func (UnimplementedHandler) AcknowledgeMyAssessmentSignalNotice(ctx context.Context, req *AssessmentSignalNoticeAcknowledgement) (r AcknowledgeMyAssessmentSignalNoticeRes, _ error) {
return r, ht.ErrNotImplemented
}
// CancelMyInvitation implements CancelMyInvitation operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -655,6 +679,33 @@ func (UnimplementedHandler) GetMyAssessmentResult(ctx context.Context, params Ge
return r, ht.ErrNotImplemented
}
// GetMyAssessmentSignalNotice implements GetMyAssessmentSignalNotice operation.
//
// Requires the session cookie of a candidate account with a confirmed email; the candidate comes from
// the session. Returns the notice version that the server requires now and whether this candidate
// acknowledged it. The notice lists the signals that are collected during a real assessment attempt
// and states that images, sound, and clipboard contents are not collected. Client signals are the time
// away from the tab or window, copy, paste and cut with a size only, and exits from fullscreen mode.
// Server signals are the response time of each item measured by the server, a change of network
// address during the attempt, parallel sessions, and the comparison of answers to variants of the same
// task by candidates. The server stores for these only one-way keyed digests: it stores no network
// address, no session token, and no answer text. Client signals are stored only while the C3 consent
// is current. The client shows it before a real attempt starts and does not start the attempt until
// the notice is acknowledged.
//
// The acknowledgement is stored on the server per account and notice version, so it survives a reload
// and a new browser. It is not a consent and never changes C3: the signal operation still requires a
// current C3 consent, and an unacknowledged notice does not make that operation fail. The demo_express
// training mode collects no signals and needs no acknowledgement.
//
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account or
// an unconfirmed email answers 403 forbidden.
//
// GET /api/v1/me/assessment-signal-notice
func (UnimplementedHandler) GetMyAssessmentSignalNotice(ctx context.Context) (r GetMyAssessmentSignalNoticeRes, _ error) {
return r, ht.ErrNotImplemented
}
// GetMyCardPreview implements GetMyCardPreview operation.
//
// Requires the session cookie of a candidate account. Returns a private preview of the permitted
@@ -1057,6 +1108,24 @@ func (UnimplementedHandler) HideOrganization(ctx context.Context, params HideOrg
return r, ht.ErrNotImplemented
}
// ListMyAssessmentResults implements ListMyAssessmentResults operation.
//
// Requires a candidate session. Returns only completed root and corrective results owned by this
// candidate, newest first by decided_at and attempt_id. demo_express training results never appear.
// The cursor is opaque and bound to this candidate and listing; a malformed or foreign cursor returns
// 400 validation_failed.
//
// A v2 result includes the category decision captured when that attempt ended, including the confirmed
// grade then in force. Legacy v1 results omit category_decision because a later category must not be
// projected backward. Later policy, bank, review, or category changes do not alter either result.
// Employers cannot read this history; their separate projection contains only the current permitted
// category and no answers.
//
// GET /api/v1/me/assessment-results
func (UnimplementedHandler) ListMyAssessmentResults(ctx context.Context, params ListMyAssessmentResultsParams) (r ListMyAssessmentResultsRes, _ error) {
return r, ht.ErrNotImplemented
}
// ListMyCardAccessHistory implements ListMyCardAccessHistory operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
@@ -155,6 +155,38 @@ func (s AccountScenario) Validate() error {
}
}
func (s *AcknowledgeMyAssessmentSignalNoticeBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *AcknowledgeMyAssessmentSignalNoticeConflict) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *AcknowledgeMyAssessmentSignalNoticeForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *AcknowledgeMyAssessmentSignalNoticeUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *AnonymousCardContent) Validate() error {
if s == nil {
return validate.ErrNilPointer
@@ -717,6 +749,152 @@ func (s *AssessmentAvailabilityHeaders) Validate() error {
return nil
}
func (s *AssessmentCategoryDecisionView) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.Status.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "status",
Error: err,
})
}
if err := func() error {
if value, ok := s.PreviousConfirmedGrade.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "previous_confirmed_grade",
Error: err,
})
}
if err := func() error {
if value, ok := s.CurrentConfirmedGrade.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "current_confirmed_grade",
Error: err,
})
}
if err := func() error {
if value, ok := s.Method.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "method",
Error: err,
})
}
if err := func() error {
if value, ok := s.Source.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "source",
Error: err,
})
}
if err := func() error {
if value, ok := s.CalibrationStatus.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "calibration_status",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s AssessmentCategoryDecisionViewMethod) Validate() error {
switch s {
case "demo_basic_pass_mark":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s AssessmentCategoryDecisionViewSource) Validate() error {
switch s {
case "synthetic_demo":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s AssessmentCategoryDecisionViewStatus) Validate() error {
switch s {
case "not_eligible":
return nil
case "not_confirmed":
return nil
case "assigned":
return nil
case "unchanged":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *AssessmentClipboardSignal) Validate() error {
if s == nil {
return validate.ErrNilPointer
@@ -1214,6 +1392,24 @@ func (s *AssessmentCorrectiveResult) Validate() error {
Error: err,
})
}
if err := func() error {
if value, ok := s.CategoryDecision.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "category_decision",
Error: err,
})
}
if err := func() error {
if value, ok := s.Strength.Get(); ok {
if err := func() error {
@@ -3470,6 +3666,24 @@ func (s *AssessmentQualifiedResult) Validate() error {
Error: err,
})
}
if err := func() error {
if value, ok := s.CategoryDecision.Get(); ok {
if err := func() error {
if err := value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "category_decision",
Error: err,
})
}
if err := func() error {
if value, ok := s.Strength.Get(); ok {
if err := func() error {
@@ -3730,6 +3944,23 @@ func (s AssessmentRealMode) Validate() error {
}
}
func (s AssessmentRealResult) Validate() error {
switch s.Type {
case AssessmentQualifiedResultAssessmentRealResult:
if err := s.AssessmentQualifiedResult.Validate(); err != nil {
return err
}
return nil
case AssessmentCorrectiveResultAssessmentRealResult:
if err := s.AssessmentCorrectiveResult.Validate(); err != nil {
return err
}
return nil
default:
return errors.Errorf("invalid type %q", s.Type)
}
}
func (s AssessmentResult) Validate() error {
switch s.Type {
case AssessmentQualifiedResultAssessmentResult:
@@ -3786,6 +4017,99 @@ func (s *AssessmentResultHeaders) Validate() error {
return nil
}
func (s *AssessmentResultHistoryPage) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if s.Items == nil {
return errors.New("nil is invalid value")
}
if err := (validate.Array{
MinLength: 0,
MinLengthSet: false,
MaxLength: 50,
MaxLengthSet: true,
}).ValidateLength(len(s.Items)); err != nil {
return errors.Wrap(err, "array")
}
var failures []validate.FieldError
for i, elem := range s.Items {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "items",
Error: err,
})
}
if err := func() error {
if err := s.Page.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "page",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentResultHistoryPageHeaders) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.CacheControl.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "CacheControl",
Error: err,
})
}
if err := func() error {
if err := s.Response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Response",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentSessions) Validate() error {
if s == nil {
return validate.ErrNilPointer
@@ -3931,6 +4255,104 @@ func (s AssessmentSignalEvent) Validate() error {
}
}
func (s *AssessmentSignalNotice) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.NoticeVersion.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "notice_version",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentSignalNoticeAcknowledgement) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.NoticeVersion.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "notice_version",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *AssessmentSignalNoticeHeaders) Validate() error {
if s == nil {
return validate.ErrNilPointer
}
var failures []validate.FieldError
if err := func() error {
if err := s.CacheControl.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "CacheControl",
Error: err,
})
}
if err := func() error {
if err := s.Response.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "Response",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s AssessmentSignalNoticeVersion) Validate() error {
alias := (int32)(s)
if err := (validate.Int{
MinSet: true,
Min: 1,
MaxSet: true,
Max: 2147483647,
MinExclusive: false,
MaxExclusive: false,
MultipleOfSet: false,
MultipleOf: 0,
Pattern: nil,
}).Validate(int64(alias)); err != nil {
return errors.Wrap(err, "int")
}
return nil
}
func (s *AssessmentSignalReceipt) Validate() error {
if s == nil {
return validate.ErrNilPointer
@@ -8765,6 +9187,22 @@ func (s *GetMyAssessmentResultUnauthorized) Validate() error {
return nil
}
func (s *GetMyAssessmentSignalNoticeForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyAssessmentSignalNoticeUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *GetMyCardPreviewForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -10412,6 +10850,30 @@ func (s ItemContent) Validate() error {
}
}
func (s *ListMyAssessmentResultsBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *ListMyAssessmentResultsForbidden) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *ListMyAssessmentResultsUnauthorized) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
return err
}
return nil
}
func (s *ListMyCardAccessHistoryBadRequest) Validate() error {
alias := (*Problem)(s)
if err := alias.Validate(); err != nil {
@@ -0,0 +1,127 @@
package httpadapter
import (
"slices"
"strings"
"testing"
"lincodex/backend/internal/adapter/primary/http/api"
)
// reviewBandTerms are fragments of the names that would carry the manual-review
// band, its reasons, or the facts behind it. The band is read by an operator
// command only; no HTTP operation, whoever calls it, may declare any of them.
var reviewBandTerms = []string{
"review_band", "integrity", "signal_review", "attempt_review", "reviewband", "answer_fingerprint",
"fingerprint", "duplicate_answer", "duplicate_evidence", "matched_integer", "matched_sequence",
"parallel_session", "parallel_alternation", "address_change", "fast_answers", "deviating_answers",
"origin_mark", "network_digest", "session_digest", "evidence_bits",
}
// declaredPropertyNames collects the names under every "properties" key of a
// decoded contract value.
func declaredPropertyNames(value any, found map[string]bool) {
switch typed := value.(type) {
case map[string]any:
for key, child := range typed {
if properties, ok := child.(map[string]any); ok && key == "properties" {
for name := range properties {
found[name] = true
}
}
declaredPropertyNames(child, found)
}
case []any:
for _, child := range typed {
declaredPropertyNames(child, found)
}
}
}
// declaredEnumValues collects every string in an "enum" array.
func declaredEnumValues(value any, found map[string]bool) {
switch typed := value.(type) {
case map[string]any:
for key, child := range typed {
if values, ok := child.([]any); ok && key == "enum" {
for _, entry := range values {
if text, ok := entry.(string); ok {
found[text] = true
}
}
}
declaredEnumValues(child, found)
}
case []any:
for _, child := range typed {
declaredEnumValues(child, found)
}
}
}
// No operation reaches the review band. Candidate reads, employer reads, and
// every other operation are walked through all references: request bodies,
// responses, parameters, and headers. The band stays server-side until staff
// roles exist; the operator command is the only reader.
func TestNoOperationReachesTheAssessmentReviewBand(t *testing.T) {
spec := parsePublicContract(t)
index := componentsIndex(t, spec)
if len(spec.Paths) == 0 {
t.Fatal("the contract declares no path")
}
operations := 0
for path, item := range spec.Paths {
operations++
value := mustJSONValue(t, item)
properties, enums := map[string]bool{}, map[string]bool{}
declaredPropertyNames(value, properties)
declaredEnumValues(value, enums)
for name := range reachableSchemas(index, value) {
lowered := strings.ToLower(name)
for _, term := range []string{"reviewband", "signalreview", "attemptreview", "assessmentreview", "fingerprint", "originmark"} {
if strings.Contains(lowered, term) {
t.Errorf("%s reaches the schema %s", path, name)
}
}
component := mustJSONValue(t, index["#/components/schemas/"+name])
declaredPropertyNames(component, properties)
declaredEnumValues(component, enums)
}
for name := range properties {
for _, term := range reviewBandTerms {
if strings.Contains(strings.ToLower(name), term) {
t.Errorf("%s declares the property %q", path, name)
}
}
if name == "band" || name == "reasons" {
t.Errorf("%s declares the property %q", path, name)
}
}
if enums["attention"] && enums["review"] {
t.Errorf("%s declares the band values attention and review", path)
}
}
if operations < 10 {
t.Fatalf("walked only %d paths, want the whole contract", operations)
}
}
// The walk is not vacuous: it reaches the signal receipt, which carries
// counts and a status and nothing of the band.
func TestSignalReceiptDeclaresNoBandAndIsReachable(t *testing.T) {
spec := parsePublicContract(t)
index := componentsIndex(t, spec)
operation := operationByID(t, spec, "RecordMyAssessmentAttemptSignals")
reached := reachableSchemas(index, mustJSONValue(t, operation))
if !reached["AssessmentSignalReceipt"] {
t.Fatalf("the signal operation reaches %v, want AssessmentSignalReceipt", reached)
}
receipt := spec.Components.Schemas["AssessmentSignalReceipt"]
if got, want := propertyNames(receipt), []string{"accepted_events", "received_at", "status"}; !slices.Equal(got, want) {
t.Errorf("AssessmentSignalReceipt properties = %v, want %v", got, want)
}
if receipt.AdditionalProperties.Bool == nil || *receipt.AdditionalProperties.Bool {
t.Error("AssessmentSignalReceipt accepts unknown properties")
}
assertNoJSONFields(t, api.AssessmentSignalReceipt{}, []string{"band", "review", "reasons", "attention"})
}
@@ -208,7 +208,7 @@ func (handler *AssessmentHandler) SubmitMyAssessmentAnswer(
result, err := operations.SubmitAnswer(ctx, assessmentusecase.SubmitAttemptAnswerCommand{
ActorID: principal.UserID, AttemptID: domain.AssessmentAttemptID(params.AttemptID),
ItemID: uuid.UUID(request.ItemID), ExpectedVersion: int64(request.ExpectedVersion),
IdempotencyKey: params.IdempotencyKey, Answer: answer,
IdempotencyKey: params.IdempotencyKey, Answer: answer, Origin: assessmentRequestOrigin(ctx),
})
if err != nil {
return assessmentAnswerFailure(ctx, err)
@@ -0,0 +1,18 @@
package v1
import (
"context"
assessmentusecase "lincodex/backend/internal/usecase/assessment"
)
// assessmentRequestOrigin hands the authenticated session and the limiter key
// of the client address to the server signals. The usecase turns them into
// keyed digests; neither value is stored or logged.
func assessmentRequestOrigin(ctx context.Context) assessmentusecase.RequestOrigin {
session, ok := sessionFromContext(ctx)
if !ok {
return assessmentusecase.RequestOrigin{}
}
return assessmentusecase.RequestOrigin{SessionID: session.SessionID, ClientKey: clientKey(ctx)}
}
@@ -23,6 +23,7 @@ type AssessmentSignalOperations interface {
// It never logs or returns event details.
type AssessmentSignalHandler struct {
operations AssessmentSignalOperations
notice AssessmentSignalNoticeOperations
}
func NewAssessmentSignalHandler(operations AssessmentSignalOperations) *AssessmentSignalHandler {
@@ -61,7 +62,7 @@ func (handler *AssessmentSignalHandler) RecordMyAssessmentAttemptSignals(
}
receipt, err := handler.operations.RecordSignals(ctx, assessmentusecase.RecordSignalsCommand{
ActorID: principal.UserID, AttemptID: domain.AssessmentAttemptID(params.AttemptID),
IdempotencyKey: params.IdempotencyKey, Events: events,
IdempotencyKey: params.IdempotencyKey, Events: events, Origin: assessmentRequestOrigin(ctx),
})
if err != nil {
return signalFailure(ctx, err)
@@ -0,0 +1,103 @@
package v1
import (
"context"
"errors"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/adapter/primary/http/api"
"lincodex/backend/internal/adapter/primary/http/problem"
assessmentusecase "lincodex/backend/internal/usecase/assessment"
)
// AssessmentSignalNoticeOperations reads and records the acknowledgement of the
// notice about collected assessment signals.
type AssessmentSignalNoticeOperations interface {
GetSignalNotice(ctx context.Context, actorID uuid.UUID) (assessmentusecase.SignalNoticeState, error)
AcknowledgeSignalNotice(ctx context.Context, actorID uuid.UUID, version int32) (assessmentusecase.SignalNoticeState, error)
}
// WithNotice serves the signal notice operations next to the signal batches.
// Without it those operations answer as not implemented.
func (handler *AssessmentSignalHandler) WithNotice(operations AssessmentSignalNoticeOperations) *AssessmentSignalHandler {
if operations == nil {
panic("v1.AssessmentSignalHandler.WithNotice - notice operations must not be nil")
}
handler.notice = operations
return handler
}
func (handler *Handler) GetMyAssessmentSignalNotice(ctx context.Context) (api.GetMyAssessmentSignalNoticeRes, error) {
if handler.assessmentSignals == nil || handler.assessmentSignals.notice == nil {
return handler.UnimplementedHandler.GetMyAssessmentSignalNotice(ctx)
}
return handler.assessmentSignals.GetMyAssessmentSignalNotice(ctx)
}
func (handler *Handler) AcknowledgeMyAssessmentSignalNotice(
ctx context.Context,
request *api.AssessmentSignalNoticeAcknowledgement,
) (api.AcknowledgeMyAssessmentSignalNoticeRes, error) {
if handler.assessmentSignals == nil || handler.assessmentSignals.notice == nil {
return handler.UnimplementedHandler.AcknowledgeMyAssessmentSignalNotice(ctx, request)
}
return handler.assessmentSignals.AcknowledgeMyAssessmentSignalNotice(ctx, request)
}
func (handler *AssessmentSignalHandler) GetMyAssessmentSignalNotice(ctx context.Context) (api.GetMyAssessmentSignalNoticeRes, error) {
principal, ok := PrincipalFromContext(ctx)
if !ok {
return (*api.GetMyAssessmentSignalNoticeUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
}
state, err := handler.notice.GetSignalNotice(ctx, principal.UserID)
if err != nil {
if isSignalNoticeForbidden(err) {
return (*api.GetMyAssessmentSignalNoticeForbidden)(&problem.New(ctx, api.ProblemCodeForbidden).Response), nil
}
return nil, err
}
return signalNoticeResponse(state), nil
}
func (handler *AssessmentSignalHandler) AcknowledgeMyAssessmentSignalNotice(
ctx context.Context,
request *api.AssessmentSignalNoticeAcknowledgement,
) (api.AcknowledgeMyAssessmentSignalNoticeRes, error) {
principal, ok := PrincipalFromContext(ctx)
if !ok {
return (*api.AcknowledgeMyAssessmentSignalNoticeUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
}
if request == nil {
return (*api.AcknowledgeMyAssessmentSignalNoticeBadRequest)(
&problem.InvalidField(ctx, api.ProblemFieldLocationBody, "").Response,
), nil
}
state, err := handler.notice.AcknowledgeSignalNotice(ctx, principal.UserID, int32(request.NoticeVersion))
switch {
case err == nil:
return signalNoticeResponse(state), nil
case isSignalNoticeForbidden(err):
return (*api.AcknowledgeMyAssessmentSignalNoticeForbidden)(&problem.New(ctx, api.ProblemCodeForbidden).Response), nil
case errors.Is(err, assessmentusecase.ErrSignalNoticeVersionMismatch):
return (*api.AcknowledgeMyAssessmentSignalNoticeConflict)(&problem.New(ctx, api.ProblemCodeStateConflict).Response), nil
default:
return nil, err
}
}
func isSignalNoticeForbidden(err error) bool {
return errors.Is(err, assessmentusecase.ErrAttemptForbidden) || errors.Is(err, assessmentusecase.ErrAttemptEmailNotVerified)
}
func signalNoticeResponse(state assessmentusecase.SignalNoticeState) *api.AssessmentSignalNoticeHeaders {
notice := api.AssessmentSignalNotice{
NoticeVersion: api.AssessmentSignalNoticeVersion(state.Version), Acknowledged: state.Acknowledged,
}
notice.AcknowledgedAt.SetToNull()
if state.Acknowledged {
notice.AcknowledgedAt.SetTo(api.Timestamp(state.AcknowledgedAt.UTC().Truncate(time.Microsecond)))
}
return &api.AssessmentSignalNoticeHeaders{CacheControl: api.CacheControlNoStoreNoStore, Response: notice}
}
@@ -0,0 +1,102 @@
package v1
import (
"context"
"fmt"
"testing"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/adapter/primary/http/api"
assessmentusecase "lincodex/backend/internal/usecase/assessment"
)
type signalNoticeStub struct {
state assessmentusecase.SignalNoticeState
err error
version int32
calls int
}
func (stub *signalNoticeStub) GetSignalNotice(context.Context, uuid.UUID) (assessmentusecase.SignalNoticeState, error) {
stub.calls++
return stub.state, stub.err
}
func (stub *signalNoticeStub) AcknowledgeSignalNotice(
_ context.Context,
_ uuid.UUID,
version int32,
) (assessmentusecase.SignalNoticeState, error) {
stub.calls++
stub.version = version
return stub.state, stub.err
}
func TestSignalNoticeHandlerReturnsNullTimeUntilAcknowledged(t *testing.T) {
stub := &signalNoticeStub{state: assessmentusecase.SignalNoticeState{Version: 1}}
handler := NewAssessmentSignalHandler(&assessmentSignalOperationsStub{}).WithNotice(stub)
result, err := handler.GetMyAssessmentSignalNotice(principalForTest(uuid.New()))
if err != nil {
t.Fatalf("GetMyAssessmentSignalNotice() error = %v", err)
}
response, ok := result.(*api.AssessmentSignalNoticeHeaders)
if !ok {
t.Fatalf("result = %T, want notice headers", result)
}
if response.CacheControl != api.CacheControlNoStoreNoStore || response.Response.Acknowledged ||
!response.Response.AcknowledgedAt.Null || response.Response.NoticeVersion != 1 {
t.Fatalf("notice response = %+v", response)
}
}
func TestSignalNoticeHandlerAcknowledgesTheSentVersion(t *testing.T) {
at := time.Date(2026, time.October, 8, 9, 0, 0, 0, time.UTC)
stub := &signalNoticeStub{state: assessmentusecase.SignalNoticeState{Version: 1, Acknowledged: true, AcknowledgedAt: at}}
handler := NewAssessmentSignalHandler(&assessmentSignalOperationsStub{}).WithNotice(stub)
result, err := handler.AcknowledgeMyAssessmentSignalNotice(
principalForTest(uuid.New()), &api.AssessmentSignalNoticeAcknowledgement{NoticeVersion: 1},
)
if err != nil {
t.Fatalf("AcknowledgeMyAssessmentSignalNotice() error = %v", err)
}
response, ok := result.(*api.AssessmentSignalNoticeHeaders)
if !ok || !response.Response.Acknowledged || response.Response.AcknowledgedAt.Null ||
!time.Time(response.Response.AcknowledgedAt.Value).Equal(at) || stub.version != 1 {
t.Fatalf("result = %#v, sent version %d", result, stub.version)
}
}
func TestSignalNoticeHandlerMapsFailuresWithoutLeakingDetails(t *testing.T) {
cases := []struct {
name string
err error
want any
}{
{"version", assessmentusecase.ErrSignalNoticeVersionMismatch, &api.AcknowledgeMyAssessmentSignalNoticeConflict{}},
{"employer", assessmentusecase.ErrAttemptForbidden, &api.AcknowledgeMyAssessmentSignalNoticeForbidden{}},
{"unverified", assessmentusecase.ErrAttemptEmailNotVerified, &api.AcknowledgeMyAssessmentSignalNoticeForbidden{}},
}
for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) {
handler := NewAssessmentSignalHandler(&assessmentSignalOperationsStub{}).WithNotice(&signalNoticeStub{err: testCase.err})
result, err := handler.AcknowledgeMyAssessmentSignalNotice(
principalForTest(uuid.New()), &api.AssessmentSignalNoticeAcknowledgement{NoticeVersion: 1},
)
if err != nil {
t.Fatalf("error = %v, want a typed problem response", err)
}
if gotType, wantType := fmt.Sprintf("%T", result), fmt.Sprintf("%T", testCase.want); gotType != wantType {
t.Fatalf("result type = %s, want %s", gotType, wantType)
}
})
}
}
func TestSignalNoticeIsNotImplementedWithoutOperations(t *testing.T) {
handler := &Handler{assessmentSignals: NewAssessmentSignalHandler(&assessmentSignalOperationsStub{})}
if _, err := handler.GetMyAssessmentSignalNotice(principalForTest(uuid.New())); err == nil {
t.Fatal("GetMyAssessmentSignalNotice() without notice operations must not answer as implemented")
}
}