feat: mail service
This commit is contained in:
@@ -62,12 +62,37 @@ func TestPublicOpenAPISpecMatchesGatewayPublicAuthContract(t *testing.T) {
|
||||
responseSchemaRef(t, gatewayOperation, http.StatusOK),
|
||||
"path "+path+" success response schema",
|
||||
)
|
||||
compareParameterRefs(
|
||||
t,
|
||||
authOperation.Parameters,
|
||||
gatewayOperation.Parameters,
|
||||
"path "+path+" parameters",
|
||||
)
|
||||
|
||||
for _, status := range publicErrorStatuses(path) {
|
||||
assertSchemaRef(t, responseSchemaRef(t, authOperation, status), errorResponseRef, "path "+path+" error response "+http.StatusText(status)+" envelope")
|
||||
}
|
||||
}
|
||||
|
||||
assertOperationParameterRefs(
|
||||
t,
|
||||
getOperation(t, authDoc, "/api/v1/public/auth/send-email-code", http.MethodPost),
|
||||
"#/components/parameters/AcceptLanguage",
|
||||
)
|
||||
assertOperationParameterRefs(
|
||||
t,
|
||||
getOperation(t, gatewayDoc, "/api/v1/public/auth/send-email-code", http.MethodPost),
|
||||
"#/components/parameters/AcceptLanguage",
|
||||
)
|
||||
assertOperationParameterRefs(
|
||||
t,
|
||||
getOperation(t, authDoc, "/api/v1/public/auth/confirm-email-code", http.MethodPost),
|
||||
)
|
||||
assertOperationParameterRefs(
|
||||
t,
|
||||
getOperation(t, gatewayDoc, "/api/v1/public/auth/confirm-email-code", http.MethodPost),
|
||||
)
|
||||
|
||||
compareSchemaRefs(
|
||||
t,
|
||||
authErrorEnvelope,
|
||||
@@ -352,6 +377,16 @@ func compareSchemaRefs(t *testing.T, got *openapi3.SchemaRef, want *openapi3.Sch
|
||||
}
|
||||
}
|
||||
|
||||
func compareParameterRefs(t *testing.T, got openapi3.Parameters, want openapi3.Parameters, name string) {
|
||||
t.Helper()
|
||||
|
||||
gotJSON := mustJSON(t, got)
|
||||
wantJSON := mustJSON(t, want)
|
||||
if !bytes.Equal(gotJSON, wantJSON) {
|
||||
require.Failf(t, "test failed", "%s mismatch:\n got: %s\nwant: %s", name, gotJSON, wantJSON)
|
||||
}
|
||||
}
|
||||
|
||||
func assertSchemaRef(t *testing.T, schemaRef *openapi3.SchemaRef, want string, name string) {
|
||||
t.Helper()
|
||||
|
||||
@@ -360,6 +395,23 @@ func assertSchemaRef(t *testing.T, schemaRef *openapi3.SchemaRef, want string, n
|
||||
}
|
||||
}
|
||||
|
||||
func assertOperationParameterRefs(t *testing.T, operation *openapi3.Operation, refs ...string) {
|
||||
t.Helper()
|
||||
|
||||
if len(operation.Parameters) != len(refs) {
|
||||
require.Failf(t, "test failed", "operation parameter count = %d, want %d", len(operation.Parameters), len(refs))
|
||||
}
|
||||
|
||||
for index, want := range refs {
|
||||
if operation.Parameters[index] == nil {
|
||||
require.Failf(t, "test failed", "operation parameter %d is nil", index)
|
||||
}
|
||||
if operation.Parameters[index].Ref != want {
|
||||
require.Failf(t, "test failed", "operation parameter %d ref = %q, want %q", index, operation.Parameters[index].Ref, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func assertRequiredFields(t *testing.T, schemaRef *openapi3.SchemaRef, fields ...string) {
|
||||
t.Helper()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user