feat(assessment): add the review band of attempt signals and the disclosed collector
This commit is contained in:
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")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
|
||||
"lincodex/backend/internal/adapter/secondary/postgres/sqlc"
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
)
|
||||
|
||||
var (
|
||||
_ outbound.AssessmentSignalNoticeRepositories = (*UnitOfWork)(nil)
|
||||
_ outbound.AssessmentSignalNoticeRepository = assessmentSignalNoticeRepository{}
|
||||
)
|
||||
|
||||
func (unit *UnitOfWork) AssessmentSignalNotices() outbound.AssessmentSignalNoticeRepository {
|
||||
return assessmentSignalNoticeRepository{queries: unit.queries}
|
||||
}
|
||||
|
||||
type assessmentSignalNoticeRepository struct {
|
||||
queries *sqlc.Queries
|
||||
}
|
||||
|
||||
func (repository assessmentSignalNoticeRepository) Get(
|
||||
ctx context.Context,
|
||||
userID uuid.UUID,
|
||||
version int32,
|
||||
) (time.Time, error) {
|
||||
const location = "assessmentSignalNoticeRepository.Get"
|
||||
if userID == uuid.Nil || version < 1 {
|
||||
return time.Time{}, fmt.Errorf("%s - user and notice version are required", location)
|
||||
}
|
||||
stored, err := repository.queries.GetAssessmentSignalNoticeAcknowledgement(ctx, sqlc.GetAssessmentSignalNoticeAcknowledgementParams{
|
||||
UserID: pgUUID(userID), NoticeVersion: version,
|
||||
})
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return time.Time{}, fmt.Errorf("%s - read acknowledgement: %w", location, outbound.ErrAssessmentSignalNoticeNotAcknowledged)
|
||||
}
|
||||
if err != nil {
|
||||
return time.Time{}, fmt.Errorf("%s - read acknowledgement: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return acknowledgementTime(location, stored)
|
||||
}
|
||||
|
||||
func (repository assessmentSignalNoticeRepository) Acknowledge(
|
||||
ctx context.Context,
|
||||
userID uuid.UUID,
|
||||
version int32,
|
||||
at time.Time,
|
||||
) (time.Time, error) {
|
||||
const location = "assessmentSignalNoticeRepository.Acknowledge"
|
||||
if userID == uuid.Nil || version < 1 || at.IsZero() {
|
||||
return time.Time{}, fmt.Errorf("%s - user, notice version, and time are required", location)
|
||||
}
|
||||
if err := repository.queries.InsertAssessmentSignalNoticeAcknowledgement(ctx, sqlc.InsertAssessmentSignalNoticeAcknowledgementParams{
|
||||
UserID: pgUUID(userID), NoticeVersion: version, AcknowledgedAt: pgTime(at),
|
||||
}); err != nil {
|
||||
return time.Time{}, fmt.Errorf("%s - insert acknowledgement: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return repository.Get(ctx, userID, version)
|
||||
}
|
||||
|
||||
func acknowledgementTime(location string, stored pgtype.Timestamptz) (time.Time, error) {
|
||||
if !stored.Valid || stored.Time.IsZero() {
|
||||
return time.Time{}, fmt.Errorf("%s - stored acknowledgement time is missing", location)
|
||||
}
|
||||
return stored.Time.UTC(), nil
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
|
||||
"lincodex/backend/internal/adapter/secondary/postgres/sqlc"
|
||||
"lincodex/backend/internal/domain"
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
)
|
||||
|
||||
func (repository assessmentSignalRepository) SaveAnswerObservation(
|
||||
ctx context.Context,
|
||||
observation domain.AssessmentAnswerObservation,
|
||||
) error {
|
||||
const location = "assessmentSignalRepository.SaveAnswerObservation"
|
||||
if err := observation.Validate(); err != nil {
|
||||
return fmt.Errorf("%s - observation is invalid: %w", location, err)
|
||||
}
|
||||
if err := repository.queries.InsertAssessmentAnswerObservation(ctx, sqlc.InsertAssessmentAnswerObservationParams{
|
||||
AttemptID: pgUUID(observation.AttemptID.UUID()), ItemInstanceID: pgUUID(observation.ItemInstanceID),
|
||||
UserID: pgUUID(observation.UserID), FamilyID: pgUUID(uuid.UUID(observation.FamilyID)),
|
||||
// The seed is stored as the two's-complement image of the uint64, which
|
||||
// keeps equality and inequality exact.
|
||||
VariantSeed: int64(observation.Seed), //nolint:gosec // The two's-complement image of the seed keeps equality exact.
|
||||
AnswerFormat: observation.AnswerFormat,
|
||||
AnswerFingerprint: observation.Fingerprint[:], KeyVersion: observation.KeyVersion,
|
||||
ElapsedMs: observation.ElapsedMS, MeasuredFromAnswer: observation.MeasuredFromAnswer,
|
||||
ObservedAt: pgTime(observation.ObservedAt),
|
||||
}); err != nil {
|
||||
return fmt.Errorf("%s - insert observation: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) SaveOriginMark(ctx context.Context, mark domain.AssessmentOriginMark) error {
|
||||
const location = "assessmentSignalRepository.SaveOriginMark"
|
||||
if err := mark.Validate(); err != nil {
|
||||
return fmt.Errorf("%s - mark is invalid: %w", location, err)
|
||||
}
|
||||
var network []byte
|
||||
if !mark.NetworkDigest.IsZero() {
|
||||
network = mark.NetworkDigest[:]
|
||||
}
|
||||
if err := repository.queries.InsertAssessmentOriginMark(ctx, sqlc.InsertAssessmentOriginMarkParams{
|
||||
ID: pgUUID(mark.ID), AttemptID: pgUUID(mark.AttemptID.UUID()), Source: string(mark.Source),
|
||||
ObservedAt: pgTime(mark.ObservedAt), SessionDigest: mark.SessionDigest[:], NetworkDigest: network,
|
||||
KeyVersion: mark.KeyVersion,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("%s - insert origin mark: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) LastOriginMark(
|
||||
ctx context.Context,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
) (domain.AssessmentOriginMark, bool, error) {
|
||||
const location = "assessmentSignalRepository.LastOriginMark"
|
||||
if attemptID.IsZero() {
|
||||
return domain.AssessmentOriginMark{}, false, fmt.Errorf("%s - attempt ID is required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
row, err := repository.queries.GetLastAssessmentOriginMark(ctx, pgUUID(attemptID.UUID()))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.AssessmentOriginMark{}, false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return domain.AssessmentOriginMark{}, false, fmt.Errorf("%s - read last mark: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
mark, err := restoreAssessmentOriginMark(row)
|
||||
if err != nil {
|
||||
return domain.AssessmentOriginMark{}, false, fmt.Errorf("%s - restore mark: %w", location, err)
|
||||
}
|
||||
return mark, true, nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) ReviewInputs(
|
||||
ctx context.Context,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
) (outbound.AssessmentReviewInputs, error) {
|
||||
const location = "assessmentSignalRepository.ReviewInputs"
|
||||
if attemptID.IsZero() {
|
||||
return outbound.AssessmentReviewInputs{}, fmt.Errorf("%s - attempt ID is required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
id := pgUUID(attemptID.UUID())
|
||||
times, err := repository.queries.ListAssessmentAnswerTimes(ctx, id)
|
||||
if err != nil {
|
||||
return outbound.AssessmentReviewInputs{}, fmt.Errorf("%s - list answer times: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
marks, err := repository.queries.ListAssessmentOriginMarks(ctx, id)
|
||||
if err != nil {
|
||||
return outbound.AssessmentReviewInputs{}, fmt.Errorf("%s - list origin marks: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
totals, err := repository.queries.GetAssessmentClientSignalTotals(ctx, id)
|
||||
if err != nil {
|
||||
return outbound.AssessmentReviewInputs{}, fmt.Errorf("%s - total client signals: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
inputs := outbound.AssessmentReviewInputs{
|
||||
ClientFocusLossMS: totals.FocusLossMs, ClientClipboardCount: totals.ClipboardEvents,
|
||||
ClientFullscreenExit: totals.FullscreenExits,
|
||||
}
|
||||
for _, row := range times {
|
||||
inputs.Answers = append(inputs.Answers, domain.AssessmentResponseSample{
|
||||
AnswerFormat: row.AnswerFormat, ElapsedMS: row.ElapsedMs, MeasuredFromAnswer: row.MeasuredFromAnswer,
|
||||
})
|
||||
}
|
||||
for _, row := range marks {
|
||||
mark, err := restoreAssessmentOriginMark(row)
|
||||
if err != nil {
|
||||
return outbound.AssessmentReviewInputs{}, fmt.Errorf("%s - restore origin mark: %w", location, err)
|
||||
}
|
||||
inputs.Marks = append(inputs.Marks, mark)
|
||||
}
|
||||
return inputs, nil
|
||||
}
|
||||
|
||||
func restoreAssessmentOriginMark(row sqlc.AssessmentAttemptOriginMark) (domain.AssessmentOriginMark, error) {
|
||||
if !row.ID.Valid || !row.AttemptID.Valid || !row.ObservedAt.Valid || len(row.SessionDigest) != len(domain.AssessmentDigest{}) ||
|
||||
len(row.NetworkDigest) != 0 && len(row.NetworkDigest) != len(domain.AssessmentDigest{}) {
|
||||
return domain.AssessmentOriginMark{}, domain.ErrInvalidAssessmentReview
|
||||
}
|
||||
mark := domain.AssessmentOriginMark{
|
||||
ID: uuid.UUID(row.ID.Bytes), AttemptID: domain.AssessmentAttemptID(row.AttemptID.Bytes),
|
||||
Source: domain.AssessmentOriginSource(row.Source), ObservedAt: row.ObservedAt.Time.UTC(),
|
||||
KeyVersion: row.KeyVersion,
|
||||
}
|
||||
copy(mark.SessionDigest[:], row.SessionDigest)
|
||||
copy(mark.NetworkDigest[:], row.NetworkDigest)
|
||||
if err := mark.Validate(); err != nil {
|
||||
return domain.AssessmentOriginMark{}, err
|
||||
}
|
||||
return mark, nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) DuplicatePairs(
|
||||
ctx context.Context,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
query outbound.AssessmentDuplicateQuery,
|
||||
) ([]outbound.AssessmentDuplicatePair, error) {
|
||||
const location = "assessmentSignalRepository.DuplicatePairs"
|
||||
if attemptID.IsZero() || query.Limit < 1 || query.IntegerCapBits < 1 || query.SequenceCapBits < 1 || query.MinBits < 0 ||
|
||||
query.EndedOnly && query.Now.IsZero() {
|
||||
return nil, fmt.Errorf("%s - attempt, caps, and bounds are required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
rows, err := repository.queries.ListAssessmentDuplicatePairs(ctx, sqlc.ListAssessmentDuplicatePairsParams{
|
||||
AttemptID: pgUUID(attemptID.UUID()), IntegerCapBits: float64(query.IntegerCapBits),
|
||||
SequenceCapBits: float64(query.SequenceCapBits), MinBits: float64(query.MinBits),
|
||||
EndedOnly: query.EndedOnly, Now: pgTime(query.Now), RowLimit: query.Limit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s - list pairs: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
pairs := make([]outbound.AssessmentDuplicatePair, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
if !row.OtherAttemptID.Valid || !row.ProductPolicyVersionID.Valid || row.EvidenceBits < 0 {
|
||||
return nil, fmt.Errorf("%s - stored pair is incomplete: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
pairs = append(pairs, outbound.AssessmentDuplicatePair{
|
||||
AttemptID: domain.AssessmentAttemptID(row.OtherAttemptID.Bytes),
|
||||
PolicyVersionID: domain.PolicyVersionID(row.ProductPolicyVersionID.Bytes),
|
||||
EvidenceBits: row.EvidenceBits, IntegerItems: row.IntegerItems, SequenceItems: row.SequenceItems,
|
||||
})
|
||||
}
|
||||
return pairs, nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) ReviewSubject(
|
||||
ctx context.Context,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
) (domain.PolicyVersionID, bool, error) {
|
||||
const location = "assessmentSignalRepository.ReviewSubject"
|
||||
if attemptID.IsZero() {
|
||||
return domain.PolicyVersionID{}, false, fmt.Errorf("%s - attempt ID is required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
policyID, err := repository.queries.GetAssessmentReviewSubject(ctx, pgUUID(attemptID.UUID()))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.PolicyVersionID{}, false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return domain.PolicyVersionID{}, false, fmt.Errorf("%s - read attempt: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
if !policyID.Valid {
|
||||
return domain.PolicyVersionID{}, false, fmt.Errorf("%s - stored policy is missing: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
return domain.PolicyVersionID(policyID.Bytes), true, nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) LockReview(ctx context.Context, attemptID domain.AssessmentAttemptID) error {
|
||||
const location = "assessmentSignalRepository.LockReview"
|
||||
if attemptID.IsZero() {
|
||||
return fmt.Errorf("%s - attempt ID is required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
if err := repository.queries.LockAssessmentReview(ctx, attemptID.String()); err != nil {
|
||||
return fmt.Errorf("%s - take advisory lock: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) SaveReview(ctx context.Context, review domain.AssessmentAttemptReview) error {
|
||||
const location = "assessmentSignalRepository.SaveReview"
|
||||
if err := review.Validate(); err != nil {
|
||||
return fmt.Errorf("%s - review is invalid: %w", location, err)
|
||||
}
|
||||
measures := review.Measures
|
||||
reasons := make([]string, 0, len(review.Outcome.Reasons))
|
||||
for _, reason := range review.Outcome.Reasons {
|
||||
reasons = append(reasons, string(reason))
|
||||
}
|
||||
if err := repository.queries.UpsertAssessmentAttemptReview(ctx, sqlc.UpsertAssessmentAttemptReviewParams{
|
||||
AttemptID: pgUUID(review.AttemptID.UUID()), PolicyVersionID: pgUUID(uuid.UUID(review.PolicyVersionID)),
|
||||
Band: string(review.Outcome.Band), Reasons: reasons, AnsweredItems: measures.AnsweredItems,
|
||||
FastAnswers: measures.FastAnswers, DeviatingAnswers: measures.DeviatingAnswers,
|
||||
ParallelAlternations: measures.ParallelAlternations, ExtraNetworks: measures.ExtraNetworks,
|
||||
MatchedIntegerItems: measures.MatchedIntegerItems, MatchedSequenceItems: measures.MatchedSequenceItems,
|
||||
DuplicateEvidenceBits: measures.DuplicateEvidenceBits, ClientFocusLossMs: measures.ClientFocusLossMS,
|
||||
ClientClipboardEvents: measures.ClientClipboardEvents, ClientFullscreenExits: measures.ClientFullscreenExits,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("%s - upsert review: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) GetReview(
|
||||
ctx context.Context,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
) (domain.AssessmentAttemptReview, error) {
|
||||
const location = "assessmentSignalRepository.GetReview"
|
||||
if attemptID.IsZero() {
|
||||
return domain.AssessmentAttemptReview{}, fmt.Errorf("%s - attempt ID is required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
row, err := repository.queries.GetAssessmentAttemptReview(ctx, pgUUID(attemptID.UUID()))
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return domain.AssessmentAttemptReview{}, fmt.Errorf("%s - review does not exist: %w", location, outbound.ErrAssessmentReviewNotFound)
|
||||
}
|
||||
if err != nil {
|
||||
return domain.AssessmentAttemptReview{}, fmt.Errorf("%s - read review: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
review, err := restoreAssessmentAttemptReview(row)
|
||||
if err != nil {
|
||||
return domain.AssessmentAttemptReview{}, fmt.Errorf("%s - restore review: %w", location, err)
|
||||
}
|
||||
return review, nil
|
||||
}
|
||||
|
||||
func restoreAssessmentAttemptReview(row sqlc.GetAssessmentAttemptReviewRow) (domain.AssessmentAttemptReview, error) {
|
||||
if !row.AttemptID.Valid || !row.PolicyVersionID.Valid || !row.EvaluatedAt.Valid || !row.UpdatedAt.Valid {
|
||||
return domain.AssessmentAttemptReview{}, domain.ErrInvalidAssessmentReview
|
||||
}
|
||||
reasons := make([]domain.AssessmentReviewReason, 0, len(row.Reasons))
|
||||
for _, reason := range row.Reasons {
|
||||
reasons = append(reasons, domain.AssessmentReviewReason(reason))
|
||||
}
|
||||
review := domain.AssessmentAttemptReview{
|
||||
AttemptID: domain.AssessmentAttemptID(row.AttemptID.Bytes),
|
||||
PolicyVersionID: domain.PolicyVersionID(row.PolicyVersionID.Bytes),
|
||||
PolicyVersion: row.PolicyVersion,
|
||||
Measures: domain.AssessmentReviewMeasures{
|
||||
AnsweredItems: row.AnsweredItems, FastAnswers: row.FastAnswers, DeviatingAnswers: row.DeviatingAnswers,
|
||||
ParallelAlternations: row.ParallelAlternations, ExtraNetworks: row.ExtraNetworks,
|
||||
MatchedIntegerItems: row.MatchedIntegerItems, MatchedSequenceItems: row.MatchedSequenceItems,
|
||||
DuplicateEvidenceBits: row.DuplicateEvidenceBits,
|
||||
ClientFocusLossMS: row.ClientFocusLossMs, ClientClipboardEvents: row.ClientClipboardEvents,
|
||||
ClientFullscreenExits: row.ClientFullscreenExits,
|
||||
},
|
||||
Outcome: domain.AssessmentReviewOutcome{
|
||||
Band: domain.AssessmentReviewBand(row.Band), Reasons: reasons,
|
||||
},
|
||||
EvaluatedAt: row.EvaluatedAt.Time.UTC(), UpdatedAt: row.UpdatedAt.Time.UTC(),
|
||||
}
|
||||
if err := review.Validate(); err != nil {
|
||||
return domain.AssessmentAttemptReview{}, err
|
||||
}
|
||||
return review, nil
|
||||
}
|
||||
|
||||
func (repository assessmentSignalRepository) RecordReviewRead(
|
||||
ctx context.Context,
|
||||
id uuid.UUID,
|
||||
attemptID domain.AssessmentAttemptID,
|
||||
actor domain.AssessmentReviewActor,
|
||||
found bool,
|
||||
at time.Time,
|
||||
) error {
|
||||
const location = "assessmentSignalRepository.RecordReviewRead"
|
||||
if id == uuid.Nil || attemptID.IsZero() || actor == "" || at.IsZero() {
|
||||
return fmt.Errorf("%s - record identifiers, attempt, actor, and time are required: %w", location, domain.ErrInvalidAssessmentReview)
|
||||
}
|
||||
if err := repository.queries.InsertAssessmentReviewRead(ctx, sqlc.InsertAssessmentReviewReadParams{
|
||||
ID: pgUUID(id), AttemptID: pgUUID(attemptID.UUID()), Actor: string(actor), Found: found, ReadAt: pgTime(at),
|
||||
}); err != nil {
|
||||
return fmt.Errorf("%s - insert read record: %w", location, mapAssessmentError(err))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: assessment_signal_notice.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getAssessmentSignalNoticeAcknowledgement = `-- name: GetAssessmentSignalNoticeAcknowledgement :one
|
||||
SELECT acknowledged_at
|
||||
FROM assessment_signal_notice_acknowledgements
|
||||
WHERE
|
||||
user_id = $1
|
||||
AND notice_version = $2
|
||||
`
|
||||
|
||||
type GetAssessmentSignalNoticeAcknowledgementParams struct {
|
||||
UserID pgtype.UUID
|
||||
NoticeVersion int32
|
||||
}
|
||||
|
||||
// The caller has already checked that the user is a candidate. A missing row
|
||||
// means the notice version was not acknowledged.
|
||||
func (q *Queries) GetAssessmentSignalNoticeAcknowledgement(ctx context.Context, arg GetAssessmentSignalNoticeAcknowledgementParams) (pgtype.Timestamptz, error) {
|
||||
row := q.db.QueryRow(ctx, getAssessmentSignalNoticeAcknowledgement, arg.UserID, arg.NoticeVersion)
|
||||
var acknowledged_at pgtype.Timestamptz
|
||||
err := row.Scan(&acknowledged_at)
|
||||
return acknowledged_at, err
|
||||
}
|
||||
|
||||
const insertAssessmentSignalNoticeAcknowledgement = `-- name: InsertAssessmentSignalNoticeAcknowledgement :exec
|
||||
INSERT INTO assessment_signal_notice_acknowledgements (user_id, notice_version, acknowledged_at)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (user_id, notice_version) DO NOTHING
|
||||
`
|
||||
|
||||
type InsertAssessmentSignalNoticeAcknowledgementParams struct {
|
||||
UserID pgtype.UUID
|
||||
NoticeVersion int32
|
||||
AcknowledgedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// The first acknowledgement wins; a repeat keeps the stored time and inserts
|
||||
// nothing. The caller reads the stored row afterwards in the same transaction.
|
||||
func (q *Queries) InsertAssessmentSignalNoticeAcknowledgement(ctx context.Context, arg InsertAssessmentSignalNoticeAcknowledgementParams) error {
|
||||
_, err := q.db.Exec(ctx, insertAssessmentSignalNoticeAcknowledgement, arg.UserID, arg.NoticeVersion, arg.AcknowledgedAt)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,577 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: assessment_signal_review.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getAssessmentAttemptReview = `-- name: GetAssessmentAttemptReview :one
|
||||
SELECT
|
||||
review.attempt_id,
|
||||
review.policy_version_id,
|
||||
policy.version AS policy_version,
|
||||
review.band,
|
||||
review.reasons,
|
||||
review.answered_items,
|
||||
review.fast_answers,
|
||||
review.deviating_answers,
|
||||
review.parallel_alternations,
|
||||
review.extra_networks,
|
||||
review.matched_integer_items,
|
||||
review.matched_sequence_items,
|
||||
review.duplicate_evidence_bits,
|
||||
review.client_focus_loss_ms,
|
||||
review.client_clipboard_events,
|
||||
review.client_fullscreen_exits,
|
||||
review.evaluated_at,
|
||||
review.updated_at
|
||||
FROM assessment_attempt_reviews AS review
|
||||
JOIN policy_versions AS policy ON policy.id = review.policy_version_id
|
||||
WHERE review.attempt_id = $1
|
||||
`
|
||||
|
||||
type GetAssessmentAttemptReviewRow struct {
|
||||
AttemptID pgtype.UUID
|
||||
PolicyVersionID pgtype.UUID
|
||||
PolicyVersion int32
|
||||
Band string
|
||||
Reasons []string
|
||||
AnsweredItems int32
|
||||
FastAnswers int32
|
||||
DeviatingAnswers int32
|
||||
ParallelAlternations int32
|
||||
ExtraNetworks int32
|
||||
MatchedIntegerItems int32
|
||||
MatchedSequenceItems int32
|
||||
DuplicateEvidenceBits int32
|
||||
ClientFocusLossMs int64
|
||||
ClientClipboardEvents int32
|
||||
ClientFullscreenExits int32
|
||||
EvaluatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) GetAssessmentAttemptReview(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentAttemptReviewRow, error) {
|
||||
row := q.db.QueryRow(ctx, getAssessmentAttemptReview, attemptID)
|
||||
var i GetAssessmentAttemptReviewRow
|
||||
err := row.Scan(
|
||||
&i.AttemptID,
|
||||
&i.PolicyVersionID,
|
||||
&i.PolicyVersion,
|
||||
&i.Band,
|
||||
&i.Reasons,
|
||||
&i.AnsweredItems,
|
||||
&i.FastAnswers,
|
||||
&i.DeviatingAnswers,
|
||||
&i.ParallelAlternations,
|
||||
&i.ExtraNetworks,
|
||||
&i.MatchedIntegerItems,
|
||||
&i.MatchedSequenceItems,
|
||||
&i.DuplicateEvidenceBits,
|
||||
&i.ClientFocusLossMs,
|
||||
&i.ClientClipboardEvents,
|
||||
&i.ClientFullscreenExits,
|
||||
&i.EvaluatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAssessmentClientSignalTotals = `-- name: GetAssessmentClientSignalTotals :one
|
||||
SELECT
|
||||
COALESCE(sum(duration_ms) FILTER (WHERE kind = 'focus_loss'), 0)::bigint AS focus_loss_ms,
|
||||
(count(*) FILTER (WHERE kind IN ('copy', 'paste', 'cut')))::integer AS clipboard_events,
|
||||
(count(*) FILTER (WHERE kind = 'fullscreen_exit'))::integer AS fullscreen_exits
|
||||
FROM assessment_signal_events
|
||||
WHERE attempt_id = $1
|
||||
`
|
||||
|
||||
type GetAssessmentClientSignalTotalsRow struct {
|
||||
FocusLossMs int64
|
||||
ClipboardEvents int32
|
||||
FullscreenExits int32
|
||||
}
|
||||
|
||||
func (q *Queries) GetAssessmentClientSignalTotals(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentClientSignalTotalsRow, error) {
|
||||
row := q.db.QueryRow(ctx, getAssessmentClientSignalTotals, attemptID)
|
||||
var i GetAssessmentClientSignalTotalsRow
|
||||
err := row.Scan(&i.FocusLossMs, &i.ClipboardEvents, &i.FullscreenExits)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAssessmentReviewSubject = `-- name: GetAssessmentReviewSubject :one
|
||||
SELECT product_policy_version_id
|
||||
FROM assessment_attempts
|
||||
WHERE id = $1 AND kind IN ('root', 'corrective')
|
||||
`
|
||||
|
||||
// The attempt a review job works on: real attempts only.
|
||||
func (q *Queries) GetAssessmentReviewSubject(ctx context.Context, attemptID pgtype.UUID) (pgtype.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, getAssessmentReviewSubject, attemptID)
|
||||
var product_policy_version_id pgtype.UUID
|
||||
err := row.Scan(&product_policy_version_id)
|
||||
return product_policy_version_id, err
|
||||
}
|
||||
|
||||
const getLastAssessmentOriginMark = `-- name: GetLastAssessmentOriginMark :one
|
||||
SELECT id, attempt_id, source, observed_at, session_digest, network_digest, key_version
|
||||
FROM assessment_attempt_origin_marks
|
||||
WHERE attempt_id = $1
|
||||
ORDER BY observed_at DESC, id DESC
|
||||
LIMIT 1
|
||||
`
|
||||
|
||||
// The caller holds the attempt row lock, so the last mark is stable.
|
||||
func (q *Queries) GetLastAssessmentOriginMark(ctx context.Context, attemptID pgtype.UUID) (AssessmentAttemptOriginMark, error) {
|
||||
row := q.db.QueryRow(ctx, getLastAssessmentOriginMark, attemptID)
|
||||
var i AssessmentAttemptOriginMark
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.AttemptID,
|
||||
&i.Source,
|
||||
&i.ObservedAt,
|
||||
&i.SessionDigest,
|
||||
&i.NetworkDigest,
|
||||
&i.KeyVersion,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertAssessmentAnswerObservation = `-- name: InsertAssessmentAnswerObservation :exec
|
||||
INSERT INTO assessment_answer_observations (
|
||||
attempt_id,
|
||||
item_instance_id,
|
||||
user_id,
|
||||
family_id,
|
||||
variant_seed,
|
||||
answer_format,
|
||||
answer_fingerprint,
|
||||
key_version,
|
||||
elapsed_ms,
|
||||
measured_from_answer,
|
||||
observed_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9,
|
||||
$10,
|
||||
$11
|
||||
)
|
||||
`
|
||||
|
||||
type InsertAssessmentAnswerObservationParams struct {
|
||||
AttemptID pgtype.UUID
|
||||
ItemInstanceID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
FamilyID pgtype.UUID
|
||||
VariantSeed int64
|
||||
AnswerFormat string
|
||||
AnswerFingerprint []byte
|
||||
KeyVersion int16
|
||||
ElapsedMs int32
|
||||
MeasuredFromAnswer bool
|
||||
ObservedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) InsertAssessmentAnswerObservation(ctx context.Context, arg InsertAssessmentAnswerObservationParams) error {
|
||||
_, err := q.db.Exec(ctx, insertAssessmentAnswerObservation,
|
||||
arg.AttemptID,
|
||||
arg.ItemInstanceID,
|
||||
arg.UserID,
|
||||
arg.FamilyID,
|
||||
arg.VariantSeed,
|
||||
arg.AnswerFormat,
|
||||
arg.AnswerFingerprint,
|
||||
arg.KeyVersion,
|
||||
arg.ElapsedMs,
|
||||
arg.MeasuredFromAnswer,
|
||||
arg.ObservedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertAssessmentOriginMark = `-- name: InsertAssessmentOriginMark :exec
|
||||
INSERT INTO assessment_attempt_origin_marks (
|
||||
id,
|
||||
attempt_id,
|
||||
source,
|
||||
observed_at,
|
||||
session_digest,
|
||||
network_digest,
|
||||
key_version
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7
|
||||
)
|
||||
`
|
||||
|
||||
type InsertAssessmentOriginMarkParams struct {
|
||||
ID pgtype.UUID
|
||||
AttemptID pgtype.UUID
|
||||
Source string
|
||||
ObservedAt pgtype.Timestamptz
|
||||
SessionDigest []byte
|
||||
NetworkDigest []byte
|
||||
KeyVersion int16
|
||||
}
|
||||
|
||||
func (q *Queries) InsertAssessmentOriginMark(ctx context.Context, arg InsertAssessmentOriginMarkParams) error {
|
||||
_, err := q.db.Exec(ctx, insertAssessmentOriginMark,
|
||||
arg.ID,
|
||||
arg.AttemptID,
|
||||
arg.Source,
|
||||
arg.ObservedAt,
|
||||
arg.SessionDigest,
|
||||
arg.NetworkDigest,
|
||||
arg.KeyVersion,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertAssessmentReviewRead = `-- name: InsertAssessmentReviewRead :exec
|
||||
INSERT INTO assessment_review_reads (id, attempt_id, actor, found, read_at)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
`
|
||||
|
||||
type InsertAssessmentReviewReadParams struct {
|
||||
ID pgtype.UUID
|
||||
AttemptID pgtype.UUID
|
||||
Actor string
|
||||
Found bool
|
||||
ReadAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) InsertAssessmentReviewRead(ctx context.Context, arg InsertAssessmentReviewReadParams) error {
|
||||
_, err := q.db.Exec(ctx, insertAssessmentReviewRead,
|
||||
arg.ID,
|
||||
arg.AttemptID,
|
||||
arg.Actor,
|
||||
arg.Found,
|
||||
arg.ReadAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const listAssessmentAnswerTimes = `-- name: ListAssessmentAnswerTimes :many
|
||||
SELECT answer_format, elapsed_ms, measured_from_answer
|
||||
FROM assessment_answer_observations
|
||||
WHERE attempt_id = $1
|
||||
ORDER BY observed_at, item_instance_id
|
||||
LIMIT 220
|
||||
`
|
||||
|
||||
type ListAssessmentAnswerTimesRow struct {
|
||||
AnswerFormat string
|
||||
ElapsedMs int32
|
||||
MeasuredFromAnswer bool
|
||||
}
|
||||
|
||||
// An attempt holds at most 220 items, so the list is bounded by the attempt.
|
||||
func (q *Queries) ListAssessmentAnswerTimes(ctx context.Context, attemptID pgtype.UUID) ([]ListAssessmentAnswerTimesRow, error) {
|
||||
rows, err := q.db.Query(ctx, listAssessmentAnswerTimes, attemptID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListAssessmentAnswerTimesRow
|
||||
for rows.Next() {
|
||||
var i ListAssessmentAnswerTimesRow
|
||||
if err := rows.Scan(&i.AnswerFormat, &i.ElapsedMs, &i.MeasuredFromAnswer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listAssessmentDuplicatePairs = `-- name: ListAssessmentDuplicatePairs :many
|
||||
WITH mine AS (
|
||||
SELECT
|
||||
own.family_id,
|
||||
own.key_version,
|
||||
own.answer_fingerprint,
|
||||
own.answer_format,
|
||||
own.variant_seed,
|
||||
own.user_id
|
||||
FROM assessment_answer_observations AS own
|
||||
WHERE own.attempt_id = $5
|
||||
),
|
||||
|
||||
pair_items AS (
|
||||
SELECT
|
||||
other.attempt_id AS other_attempt_id,
|
||||
mine.answer_format,
|
||||
least(
|
||||
CASE
|
||||
WHEN mine.answer_format = 'integer' THEN $6::float8
|
||||
ELSE $7::float8
|
||||
END,
|
||||
greatest(0::float8, -ln(holders.holders::float8 / totals.answer_count::float8) / ln(2::float8))
|
||||
) AS bits
|
||||
FROM mine
|
||||
INNER JOIN assessment_answer_observations AS other
|
||||
ON mine.family_id = other.family_id
|
||||
AND mine.key_version = other.key_version
|
||||
AND mine.answer_fingerprint = other.answer_fingerprint
|
||||
AND mine.user_id <> other.user_id
|
||||
AND mine.variant_seed <> other.variant_seed
|
||||
INNER JOIN assessment_answer_fingerprint_holders AS holders
|
||||
ON mine.family_id = holders.family_id
|
||||
AND mine.key_version = holders.key_version
|
||||
AND mine.answer_fingerprint = holders.answer_fingerprint
|
||||
INNER JOIN assessment_answer_family_totals AS totals
|
||||
ON mine.family_id = totals.family_id
|
||||
AND mine.key_version = totals.key_version
|
||||
)
|
||||
|
||||
SELECT
|
||||
pair_items.other_attempt_id,
|
||||
other_attempt.product_policy_version_id,
|
||||
floor(sum(pair_items.bits))::integer AS evidence_bits,
|
||||
(count(*) FILTER (WHERE pair_items.answer_format = 'integer'))::integer AS integer_items,
|
||||
(count(*) FILTER (WHERE pair_items.answer_format = 'integer_sequence'))::integer AS sequence_items
|
||||
FROM pair_items
|
||||
INNER JOIN assessment_attempts AS other_attempt ON pair_items.other_attempt_id = other_attempt.id
|
||||
WHERE
|
||||
NOT $1::boolean
|
||||
OR other_attempt.state IN ('completed', 'expired', 'insufficient_bank')
|
||||
OR other_attempt.expires_at <= $2::timestamptz
|
||||
GROUP BY pair_items.other_attempt_id, other_attempt.product_policy_version_id
|
||||
HAVING floor(sum(pair_items.bits)) >= $3::float8
|
||||
ORDER BY evidence_bits DESC, pair_items.other_attempt_id
|
||||
LIMIT $4
|
||||
`
|
||||
|
||||
type ListAssessmentDuplicatePairsParams struct {
|
||||
EndedOnly bool
|
||||
Now pgtype.Timestamptz
|
||||
MinBits float64
|
||||
RowLimit int32
|
||||
AttemptID pgtype.UUID
|
||||
IntegerCapBits float64
|
||||
SequenceCapBits float64
|
||||
}
|
||||
|
||||
type ListAssessmentDuplicatePairsRow struct {
|
||||
OtherAttemptID pgtype.UUID
|
||||
ProductPolicyVersionID pgtype.UUID
|
||||
EvidenceBits int32
|
||||
IntegerItems int32
|
||||
SequenceItems int32
|
||||
}
|
||||
|
||||
// Compares this attempt with every other attempt separately. A matched answer
|
||||
// is an equal fingerprint of the same family version under the same key
|
||||
// generation, given by another candidate to a different seed variant. It
|
||||
// carries -log2 of the share of answers that hold that fingerprint, read from
|
||||
// the maintained counters, between
|
||||
// zero and the cap of its format, and the bits of one pair add up. Pairs under
|
||||
// min_bits are dropped, the strongest come first, and the list is bounded.
|
||||
// An attempt has ended when its state is terminal or its deadline has passed.
|
||||
func (q *Queries) ListAssessmentDuplicatePairs(ctx context.Context, arg ListAssessmentDuplicatePairsParams) ([]ListAssessmentDuplicatePairsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listAssessmentDuplicatePairs,
|
||||
arg.EndedOnly,
|
||||
arg.Now,
|
||||
arg.MinBits,
|
||||
arg.RowLimit,
|
||||
arg.AttemptID,
|
||||
arg.IntegerCapBits,
|
||||
arg.SequenceCapBits,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListAssessmentDuplicatePairsRow
|
||||
for rows.Next() {
|
||||
var i ListAssessmentDuplicatePairsRow
|
||||
if err := rows.Scan(
|
||||
&i.OtherAttemptID,
|
||||
&i.ProductPolicyVersionID,
|
||||
&i.EvidenceBits,
|
||||
&i.IntegerItems,
|
||||
&i.SequenceItems,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listAssessmentOriginMarks = `-- name: ListAssessmentOriginMarks :many
|
||||
SELECT id, attempt_id, source, observed_at, session_digest, network_digest, key_version
|
||||
FROM assessment_attempt_origin_marks
|
||||
WHERE attempt_id = $1
|
||||
ORDER BY observed_at, id
|
||||
LIMIT 5000
|
||||
`
|
||||
|
||||
// Marks exist only where the session or the network changed. The bound keeps a
|
||||
// request that flaps between networks from growing the list without limit.
|
||||
func (q *Queries) ListAssessmentOriginMarks(ctx context.Context, attemptID pgtype.UUID) ([]AssessmentAttemptOriginMark, error) {
|
||||
rows, err := q.db.Query(ctx, listAssessmentOriginMarks, attemptID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []AssessmentAttemptOriginMark
|
||||
for rows.Next() {
|
||||
var i AssessmentAttemptOriginMark
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.AttemptID,
|
||||
&i.Source,
|
||||
&i.ObservedAt,
|
||||
&i.SessionDigest,
|
||||
&i.NetworkDigest,
|
||||
&i.KeyVersion,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const lockAssessmentReview = `-- name: LockAssessmentReview :exec
|
||||
SELECT pg_advisory_xact_lock(hashtextextended(
|
||||
'lincodex.assessment.signal_review:' || $1::text,
|
||||
0
|
||||
))
|
||||
`
|
||||
|
||||
// Serializes the evaluations of one review. A job takes these locks for every
|
||||
// attempt it will write, in ascending attempt order, before it reads any fact,
|
||||
// so what it reads is what the previous writer committed.
|
||||
func (q *Queries) LockAssessmentReview(ctx context.Context, attemptID string) error {
|
||||
_, err := q.db.Exec(ctx, lockAssessmentReview, attemptID)
|
||||
return err
|
||||
}
|
||||
|
||||
const upsertAssessmentAttemptReview = `-- name: UpsertAssessmentAttemptReview :exec
|
||||
INSERT INTO assessment_attempt_reviews (
|
||||
attempt_id,
|
||||
policy_version_id,
|
||||
band,
|
||||
reasons,
|
||||
answered_items,
|
||||
fast_answers,
|
||||
deviating_answers,
|
||||
parallel_alternations,
|
||||
extra_networks,
|
||||
matched_integer_items,
|
||||
matched_sequence_items,
|
||||
duplicate_evidence_bits,
|
||||
client_focus_loss_ms,
|
||||
client_clipboard_events,
|
||||
client_fullscreen_exits,
|
||||
evaluated_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4::text[],
|
||||
$5,
|
||||
$6,
|
||||
$7,
|
||||
$8,
|
||||
$9,
|
||||
$10,
|
||||
$11,
|
||||
$12,
|
||||
$13,
|
||||
$14,
|
||||
$15,
|
||||
clock_timestamp(),
|
||||
clock_timestamp()
|
||||
)
|
||||
ON CONFLICT (attempt_id) DO UPDATE SET
|
||||
policy_version_id = EXCLUDED.policy_version_id,
|
||||
band = EXCLUDED.band,
|
||||
reasons = EXCLUDED.reasons,
|
||||
answered_items = EXCLUDED.answered_items,
|
||||
fast_answers = EXCLUDED.fast_answers,
|
||||
deviating_answers = EXCLUDED.deviating_answers,
|
||||
parallel_alternations = EXCLUDED.parallel_alternations,
|
||||
extra_networks = EXCLUDED.extra_networks,
|
||||
matched_integer_items = EXCLUDED.matched_integer_items,
|
||||
matched_sequence_items = EXCLUDED.matched_sequence_items,
|
||||
duplicate_evidence_bits = EXCLUDED.duplicate_evidence_bits,
|
||||
client_focus_loss_ms = EXCLUDED.client_focus_loss_ms,
|
||||
client_clipboard_events = EXCLUDED.client_clipboard_events,
|
||||
client_fullscreen_exits = EXCLUDED.client_fullscreen_exits,
|
||||
updated_at = greatest(
|
||||
clock_timestamp(), assessment_attempt_reviews.evaluated_at, assessment_attempt_reviews.updated_at
|
||||
)
|
||||
`
|
||||
|
||||
type UpsertAssessmentAttemptReviewParams struct {
|
||||
AttemptID pgtype.UUID
|
||||
PolicyVersionID pgtype.UUID
|
||||
Band string
|
||||
Reasons []string
|
||||
AnsweredItems int32
|
||||
FastAnswers int32
|
||||
DeviatingAnswers int32
|
||||
ParallelAlternations int32
|
||||
ExtraNetworks int32
|
||||
MatchedIntegerItems int32
|
||||
MatchedSequenceItems int32
|
||||
DuplicateEvidenceBits int32
|
||||
ClientFocusLossMs int64
|
||||
ClientClipboardEvents int32
|
||||
ClientFullscreenExits int32
|
||||
}
|
||||
|
||||
// The times come from the database clock, never from a caller, and the update
|
||||
// time cannot fall behind the stored times, so two jobs writing one review in
|
||||
// either order keep the order check. The first evaluation time and the policy
|
||||
// version stay; the guard trigger refuses a change of either.
|
||||
func (q *Queries) UpsertAssessmentAttemptReview(ctx context.Context, arg UpsertAssessmentAttemptReviewParams) error {
|
||||
_, err := q.db.Exec(ctx, upsertAssessmentAttemptReview,
|
||||
arg.AttemptID,
|
||||
arg.PolicyVersionID,
|
||||
arg.Band,
|
||||
arg.Reasons,
|
||||
arg.AnsweredItems,
|
||||
arg.FastAnswers,
|
||||
arg.DeviatingAnswers,
|
||||
arg.ParallelAlternations,
|
||||
arg.ExtraNetworks,
|
||||
arg.MatchedIntegerItems,
|
||||
arg.MatchedSequenceItems,
|
||||
arg.DuplicateEvidenceBits,
|
||||
arg.ClientFocusLossMs,
|
||||
arg.ClientClipboardEvents,
|
||||
arg.ClientFullscreenExits,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -16,6 +16,33 @@ type AccountDeletionRequest struct {
|
||||
CompletedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentAnswerFamilyTotal struct {
|
||||
FamilyID pgtype.UUID
|
||||
KeyVersion int16
|
||||
AnswerCount int32
|
||||
}
|
||||
|
||||
type AssessmentAnswerFingerprintHolder struct {
|
||||
FamilyID pgtype.UUID
|
||||
KeyVersion int16
|
||||
AnswerFingerprint []byte
|
||||
Holders int32
|
||||
}
|
||||
|
||||
type AssessmentAnswerObservation struct {
|
||||
AttemptID pgtype.UUID
|
||||
ItemInstanceID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
FamilyID pgtype.UUID
|
||||
VariantSeed int64
|
||||
AnswerFormat string
|
||||
AnswerFingerprint []byte
|
||||
KeyVersion int16
|
||||
ElapsedMs int32
|
||||
MeasuredFromAnswer bool
|
||||
ObservedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentAttempt struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
@@ -74,6 +101,16 @@ type AssessmentAttemptItem struct {
|
||||
AnsweredAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentAttemptOriginMark struct {
|
||||
ID pgtype.UUID
|
||||
AttemptID pgtype.UUID
|
||||
Source string
|
||||
ObservedAt pgtype.Timestamptz
|
||||
SessionDigest []byte
|
||||
NetworkDigest []byte
|
||||
KeyVersion int16
|
||||
}
|
||||
|
||||
type AssessmentAttemptResult struct {
|
||||
AttemptID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
@@ -99,6 +136,26 @@ type AssessmentAttemptResult struct {
|
||||
DecidedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentAttemptReview struct {
|
||||
AttemptID pgtype.UUID
|
||||
PolicyVersionID pgtype.UUID
|
||||
Band string
|
||||
Reasons []string
|
||||
AnsweredItems int32
|
||||
FastAnswers int32
|
||||
DeviatingAnswers int32
|
||||
ParallelAlternations int32
|
||||
ExtraNetworks int32
|
||||
MatchedIntegerItems int32
|
||||
MatchedSequenceItems int32
|
||||
DuplicateEvidenceBits int32
|
||||
ClientFocusLossMs int64
|
||||
ClientClipboardEvents int32
|
||||
ClientFullscreenExits int32
|
||||
EvaluatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentCategoryCatalogBinding struct {
|
||||
OpeningID pgtype.UUID
|
||||
Specialization string
|
||||
@@ -143,6 +200,14 @@ type AssessmentFamily struct {
|
||||
RetiredBy pgtype.Text
|
||||
}
|
||||
|
||||
type AssessmentReviewRead struct {
|
||||
ID pgtype.UUID
|
||||
AttemptID pgtype.UUID
|
||||
Actor string
|
||||
Found bool
|
||||
ReadAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentSignalBatch struct {
|
||||
ID pgtype.UUID
|
||||
AttemptID pgtype.UUID
|
||||
@@ -169,6 +234,12 @@ type AssessmentSignalIdempotencyOutcome struct {
|
||||
ReceivedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentSignalNoticeAcknowledgement struct {
|
||||
UserID pgtype.UUID
|
||||
NoticeVersion int32
|
||||
AcknowledgedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type AssessmentTrainingBankBinding struct {
|
||||
ID pgtype.UUID
|
||||
Category string
|
||||
|
||||
@@ -227,15 +227,22 @@ type Querier interface {
|
||||
GetAssessmentAttemptKindForCandidate(ctx context.Context, arg GetAssessmentAttemptKindForCandidateParams) (string, error)
|
||||
// Reads a result only for the owning candidate.
|
||||
GetAssessmentAttemptResult(ctx context.Context, arg GetAssessmentAttemptResultParams) (string, error)
|
||||
GetAssessmentAttemptReview(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentAttemptReviewRow, error)
|
||||
// Reads an active real attempt without taking the write lock used by create.
|
||||
// The availability GET never expires or otherwise mutates this row.
|
||||
GetAssessmentAvailabilityActiveAttempt(ctx context.Context, arg GetAssessmentAvailabilityActiveAttemptParams) (GetAssessmentAvailabilityActiveAttemptRow, error)
|
||||
GetAssessmentClientSignalTotals(ctx context.Context, attemptID pgtype.UUID) (GetAssessmentClientSignalTotalsRow, error)
|
||||
GetAssessmentFamilyByID(ctx context.Context, id pgtype.UUID) (AssessmentFamily, error)
|
||||
GetAssessmentFamilyVersion(ctx context.Context, arg GetAssessmentFamilyVersionParams) (AssessmentFamily, error)
|
||||
// The attempt a review job works on: real attempts only.
|
||||
GetAssessmentReviewSubject(ctx context.Context, attemptID pgtype.UUID) (pgtype.UUID, error)
|
||||
// Counts eligible root attempts in a policy window and computes the instant
|
||||
// at which one additional root slot opens. The microsecond adjustment matches
|
||||
// the creation predicate created_at >= since at PostgreSQL timestamp precision.
|
||||
GetAssessmentRootQuotaAvailability(ctx context.Context, arg GetAssessmentRootQuotaAvailabilityParams) (GetAssessmentRootQuotaAvailabilityRow, error)
|
||||
// The caller has already checked that the user is a candidate. A missing row
|
||||
// means the notice version was not acknowledged.
|
||||
GetAssessmentSignalNoticeAcknowledgement(ctx context.Context, arg GetAssessmentSignalNoticeAcknowledgementParams) (pgtype.Timestamptz, error)
|
||||
// Read only the receipt associated with the reserved idempotency scope.
|
||||
GetAssessmentSignalOutcome(ctx context.Context, scopeHash []byte) (GetAssessmentSignalOutcomeRow, error)
|
||||
// Reads one hiding of the candidate with the current name of the
|
||||
@@ -272,6 +279,8 @@ type Querier interface {
|
||||
GetEmailTokenByHash(ctx context.Context, arg GetEmailTokenByHashParams) (EmailToken, error)
|
||||
// Explains why ConsumeEmailToken matched no row.
|
||||
GetEmailTokenState(ctx context.Context, arg GetEmailTokenStateParams) (GetEmailTokenStateRow, error)
|
||||
// The caller holds the attempt row lock, so the last mark is stable.
|
||||
GetLastAssessmentOriginMark(ctx context.Context, attemptID pgtype.UUID) (AssessmentAttemptOriginMark, error)
|
||||
GetLatestAssessmentFamily(ctx context.Context, familyKey string) (AssessmentFamily, error)
|
||||
// Reads the status of the newest delivery of a kind addressed to an account,
|
||||
// for the account's own view of its mail. It selects no address and no
|
||||
@@ -328,6 +337,7 @@ type Querier interface {
|
||||
GetUnrevokedConsentRecordByVersion(ctx context.Context, arg GetUnrevokedConsentRecordByVersionParams) (GetUnrevokedConsentRecordByVersionRow, error)
|
||||
GetUserByEmailNormalized(ctx context.Context, emailNormalized string) (User, error)
|
||||
GetUserByID(ctx context.Context, id pgtype.UUID) (User, error)
|
||||
InsertAssessmentAnswerObservation(ctx context.Context, arg InsertAssessmentAnswerObservationParams) error
|
||||
// Inserts the attempt header. The database guard rechecks the current policy,
|
||||
// opening or disjoint training binding, and immutable pins.
|
||||
InsertAssessmentAttempt(ctx context.Context, arg InsertAssessmentAttemptParams) error
|
||||
@@ -351,12 +361,17 @@ type Querier interface {
|
||||
// returns no row instead of an error, so a conflict does not abort the
|
||||
// surrounding transaction.
|
||||
InsertAssessmentFamily(ctx context.Context, arg InsertAssessmentFamilyParams) (AssessmentFamily, error)
|
||||
InsertAssessmentOriginMark(ctx context.Context, arg InsertAssessmentOriginMarkParams) error
|
||||
InsertAssessmentReviewRead(ctx context.Context, arg InsertAssessmentReviewReadParams) error
|
||||
// The attempt row is already locked by the caller. Store a parent before its
|
||||
// bounded child events, in the same transaction as the immutable receipt.
|
||||
InsertAssessmentSignalBatch(ctx context.Context, arg InsertAssessmentSignalBatchParams) error
|
||||
// Each inserted event is checked by the database guard against attempt state
|
||||
// and the aggregate capacity as a second line of defense.
|
||||
InsertAssessmentSignalEvent(ctx context.Context, arg InsertAssessmentSignalEventParams) error
|
||||
// The first acknowledgement wins; a repeat keeps the stored time and inserts
|
||||
// nothing. The caller reads the stored row afterwards in the same transaction.
|
||||
InsertAssessmentSignalNoticeAcknowledgement(ctx context.Context, arg InsertAssessmentSignalNoticeAcknowledgementParams) error
|
||||
// Save exactly one immutable response receipt for each live idempotency scope.
|
||||
InsertAssessmentSignalOutcome(ctx context.Context, arg InsertAssessmentSignalOutcomeParams) error
|
||||
// Records a successfully authorized view after visibility and quota checks.
|
||||
@@ -473,6 +488,8 @@ type Querier interface {
|
||||
// Read the latest serialized event so a temporarily regressing application
|
||||
// clock cannot make the next request fall before an event already counted.
|
||||
LatestSupportCaseRequestEvent(ctx context.Context, ownerID pgtype.UUID) (pgtype.Timestamptz, error)
|
||||
// An attempt holds at most 220 items, so the list is bounded by the attempt.
|
||||
ListAssessmentAnswerTimes(ctx context.Context, attemptID pgtype.UUID) ([]ListAssessmentAnswerTimesRow, error)
|
||||
// Reads chain headers in creation order. The use case verifies root eligibility
|
||||
// and descending target grades in the domain before it creates a correction.
|
||||
ListAssessmentAttemptChain(ctx context.Context, arg ListAssessmentAttemptChainParams) ([]AssessmentAttempt, error)
|
||||
@@ -488,10 +505,22 @@ type Querier interface {
|
||||
// Counting the first unanswered item after expiry is conservative when the
|
||||
// final response was lost, while frozen future items remain excluded.
|
||||
ListAssessmentDisclosedFamilyKeys(ctx context.Context, arg ListAssessmentDisclosedFamilyKeysParams) ([]string, error)
|
||||
// Compares this attempt with every other attempt separately. A matched answer
|
||||
// is an equal fingerprint of the same family version under the same key
|
||||
// generation, given by another candidate to a different seed variant. It
|
||||
// carries -log2 of the share of answers that hold that fingerprint, read from
|
||||
// the maintained counters, between
|
||||
// zero and the cap of its format, and the bits of one pair add up. Pairs under
|
||||
// min_bits are dropped, the strongest come first, and the list is bounded.
|
||||
// An attempt has ended when its state is terminal or its deadline has passed.
|
||||
ListAssessmentDuplicatePairs(ctx context.Context, arg ListAssessmentDuplicatePairsParams) ([]ListAssessmentDuplicatePairsRow, error)
|
||||
// One page of the versions of a category in key and version order, after the
|
||||
// given position; an empty key and version 0 start at the beginning. The
|
||||
// (family_key, version) unique index serves the scan.
|
||||
ListAssessmentFamiliesByCategory(ctx context.Context, arg ListAssessmentFamiliesByCategoryParams) ([]AssessmentFamily, error)
|
||||
// Marks exist only where the session or the network changed. The bound keeps a
|
||||
// request that flaps between networks from growing the list without limit.
|
||||
ListAssessmentOriginMarks(ctx context.Context, attemptID pgtype.UUID) ([]AssessmentAttemptOriginMark, error)
|
||||
// Reads the exact family membership pinned by a training binding.
|
||||
ListAssessmentTrainingBindingFamilies(ctx context.Context, bindingID pgtype.UUID) ([]ListAssessmentTrainingBindingFamiliesRow, error)
|
||||
// Lists only the current candidate's own access history. It deliberately
|
||||
@@ -566,6 +595,10 @@ type Querier interface {
|
||||
// published or open the category, until the transaction ends. The key is
|
||||
// namespaced, so it cannot collide with another use of advisory locks.
|
||||
LockAssessmentCategory(ctx context.Context, category string) error
|
||||
// Serializes the evaluations of one review. A job takes these locks for every
|
||||
// attempt it will write, in ascending attempt order, before it reads any fact,
|
||||
// so what it reads is what the previous writer committed.
|
||||
LockAssessmentReview(ctx context.Context, attemptID string) error
|
||||
// Lock the account before an organization checks candidate visibility. The
|
||||
// hidden-organization insert trigger takes FOR NO KEY UPDATE on this row, so
|
||||
// a hide either commits before the later visibility recheck or waits for the
|
||||
@@ -895,6 +928,11 @@ type Querier interface {
|
||||
// registrant never stands for the new one; the new registration records its
|
||||
// own C1 in the same transaction. A version conflict deletes nothing.
|
||||
UpdateUserRegistration(ctx context.Context, arg UpdateUserRegistrationParams) (UpdateUserRegistrationRow, error)
|
||||
// The times come from the database clock, never from a caller, and the update
|
||||
// time cannot fall behind the stored times, so two jobs writing one review in
|
||||
// either order keep the order check. The first evaluation time and the policy
|
||||
// version stay; the guard trigger refuses a change of either.
|
||||
UpsertAssessmentAttemptReview(ctx context.Context, arg UpsertAssessmentAttemptReviewParams) error
|
||||
}
|
||||
|
||||
var _ Querier = (*Queries)(nil)
|
||||
Reference in new issue
Block a user