From cef4653c2f02d0bf5f8261cc0344438260aac4d1 Mon Sep 17 00:00:00 2001 From: Andrew Martinez Date: Mon, 26 Jul 2021 16:19:16 -0400 Subject: [PATCH] add missing 401s to list operations, missing required - adds missing 401s to list operations that were missing them - adds required status to identityNameFormat for CAs --- controller/internal/routes/ca_api_model.go | 2 +- ...rent_api_session_certificates_responses.go | 38 +++ rest_client_api_server/embedded_spec.go | 48 ++++ ...rent_api_session_certificates_responses.go | 44 ++++ .../list_api_sessions_responses.go | 38 +++ .../list_cas_responses.go | 38 +++ .../config/list_config_types_responses.go | 38 +++ .../list_posture_check_types_responses.go | 38 +++ .../list_posture_checks_responses.go | 38 +++ rest_management_api_server/embedded_spec.go | 246 +++++++++++++++++- .../list_api_sessions_responses.go | 44 ++++ .../list_cas_responses.go | 44 ++++ .../config/list_config_types_responses.go | 44 ++++ .../list_posture_check_types_responses.go | 44 ++++ .../list_posture_checks_responses.go | 44 ++++ rest_model/ca_update.go | 16 +- specs/client.yml | 19 ++ specs/management.yml | 96 +++++++ .../current-api-session-certificates.yml | 2 + specs/source/management/api-sessions.yml | 2 + specs/source/management/cas.yml | 3 + specs/source/management/config-types.yml | 2 + .../source/management/posture-check-types.yml | 2 + specs/source/management/posture-checks.yml | 2 + tests/ca_test.go | 12 + 25 files changed, 940 insertions(+), 4 deletions(-) diff --git a/controller/internal/routes/ca_api_model.go b/controller/internal/routes/ca_api_model.go index 0dcbf11ba..4d95f522a 100644 --- a/controller/internal/routes/ca_api_model.go +++ b/controller/internal/routes/ca_api_model.go @@ -91,7 +91,7 @@ func MapUpdateCaToModel(id string, ca *rest_model.CaUpdate) *model.Ca { IsOttCaEnrollmentEnabled: ca.IsOttCaEnrollmentEnabled != nil && *ca.IsOttCaEnrollmentEnabled, IsAuthEnabled: ca.IsAuthEnabled != nil && *ca.IsAuthEnabled, IdentityRoles: ca.IdentityRoles, - IdentityNameFormat: ca.IdentityNameFormat, + IdentityNameFormat: stringz.OrEmpty(ca.IdentityNameFormat), } return ret diff --git a/rest_client_api_client/current_api_session/list_current_api_session_certificates_responses.go b/rest_client_api_client/current_api_session/list_current_api_session_certificates_responses.go index f74ea800c..91eb6d23f 100644 --- a/rest_client_api_client/current_api_session/list_current_api_session_certificates_responses.go +++ b/rest_client_api_client/current_api_session/list_current_api_session_certificates_responses.go @@ -53,6 +53,12 @@ func (o *ListCurrentAPISessionCertificatesReader) ReadResponse(response runtime. return nil, err } return result, nil + case 401: + result := NewListCurrentAPISessionCertificatesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListCurrentAPISessionCertificatesOK) readResponse(response runtime.Clie return nil } + +// NewListCurrentAPISessionCertificatesUnauthorized creates a ListCurrentAPISessionCertificatesUnauthorized with default headers values +func NewListCurrentAPISessionCertificatesUnauthorized() *ListCurrentAPISessionCertificatesUnauthorized { + return &ListCurrentAPISessionCertificatesUnauthorized{} +} + +/* ListCurrentAPISessionCertificatesUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListCurrentAPISessionCertificatesUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListCurrentAPISessionCertificatesUnauthorized) Error() string { + return fmt.Sprintf("[GET /current-api-session/certificates][%d] listCurrentApiSessionCertificatesUnauthorized %+v", 401, o.Payload) +} +func (o *ListCurrentAPISessionCertificatesUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListCurrentAPISessionCertificatesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_client_api_server/embedded_spec.go b/rest_client_api_server/embedded_spec.go index c03afdb00..5ec9f357b 100644 --- a/rest_client_api_server/embedded_spec.go +++ b/rest_client_api_server/embedded_spec.go @@ -442,6 +442,30 @@ func init() { "schema": { "$ref": "#/definitions/listCurrentApiSessionCertificatesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -5707,6 +5731,30 @@ func init() { "schema": { "$ref": "#/definitions/listCurrentApiSessionCertificatesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, diff --git a/rest_client_api_server/operations/current_api_session/list_current_api_session_certificates_responses.go b/rest_client_api_server/operations/current_api_session/list_current_api_session_certificates_responses.go index 947e29637..d98c5e53d 100644 --- a/rest_client_api_server/operations/current_api_session/list_current_api_session_certificates_responses.go +++ b/rest_client_api_server/operations/current_api_session/list_current_api_session_certificates_responses.go @@ -80,3 +80,47 @@ func (o *ListCurrentAPISessionCertificatesOK) WriteResponse(rw http.ResponseWrit } } } + +// ListCurrentAPISessionCertificatesUnauthorizedCode is the HTTP code returned for type ListCurrentAPISessionCertificatesUnauthorized +const ListCurrentAPISessionCertificatesUnauthorizedCode int = 401 + +/*ListCurrentAPISessionCertificatesUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listCurrentApiSessionCertificatesUnauthorized +*/ +type ListCurrentAPISessionCertificatesUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListCurrentAPISessionCertificatesUnauthorized creates ListCurrentAPISessionCertificatesUnauthorized with default headers values +func NewListCurrentAPISessionCertificatesUnauthorized() *ListCurrentAPISessionCertificatesUnauthorized { + + return &ListCurrentAPISessionCertificatesUnauthorized{} +} + +// WithPayload adds the payload to the list current Api session certificates unauthorized response +func (o *ListCurrentAPISessionCertificatesUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListCurrentAPISessionCertificatesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list current Api session certificates unauthorized response +func (o *ListCurrentAPISessionCertificatesUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListCurrentAPISessionCertificatesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_management_api_client/api_session/list_api_sessions_responses.go b/rest_management_api_client/api_session/list_api_sessions_responses.go index 4abdf78de..e25305094 100644 --- a/rest_management_api_client/api_session/list_api_sessions_responses.go +++ b/rest_management_api_client/api_session/list_api_sessions_responses.go @@ -53,6 +53,12 @@ func (o *ListAPISessionsReader) ReadResponse(response runtime.ClientResponse, co return nil, err } return result, nil + case 401: + result := NewListAPISessionsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListAPISessionsOK) readResponse(response runtime.ClientResponse, consum return nil } + +// NewListAPISessionsUnauthorized creates a ListAPISessionsUnauthorized with default headers values +func NewListAPISessionsUnauthorized() *ListAPISessionsUnauthorized { + return &ListAPISessionsUnauthorized{} +} + +/* ListAPISessionsUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListAPISessionsUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListAPISessionsUnauthorized) Error() string { + return fmt.Sprintf("[GET /api-sessions][%d] listApiSessionsUnauthorized %+v", 401, o.Payload) +} +func (o *ListAPISessionsUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListAPISessionsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_management_api_client/certificate_authority/list_cas_responses.go b/rest_management_api_client/certificate_authority/list_cas_responses.go index 579dd87e5..c5c34971c 100644 --- a/rest_management_api_client/certificate_authority/list_cas_responses.go +++ b/rest_management_api_client/certificate_authority/list_cas_responses.go @@ -53,6 +53,12 @@ func (o *ListCasReader) ReadResponse(response runtime.ClientResponse, consumer r return nil, err } return result, nil + case 401: + result := NewListCasUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListCasOK) readResponse(response runtime.ClientResponse, consumer runti return nil } + +// NewListCasUnauthorized creates a ListCasUnauthorized with default headers values +func NewListCasUnauthorized() *ListCasUnauthorized { + return &ListCasUnauthorized{} +} + +/* ListCasUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListCasUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListCasUnauthorized) Error() string { + return fmt.Sprintf("[GET /cas][%d] listCasUnauthorized %+v", 401, o.Payload) +} +func (o *ListCasUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListCasUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_management_api_client/config/list_config_types_responses.go b/rest_management_api_client/config/list_config_types_responses.go index 51dd1fb27..49a9cfc0f 100644 --- a/rest_management_api_client/config/list_config_types_responses.go +++ b/rest_management_api_client/config/list_config_types_responses.go @@ -53,6 +53,12 @@ func (o *ListConfigTypesReader) ReadResponse(response runtime.ClientResponse, co return nil, err } return result, nil + case 401: + result := NewListConfigTypesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListConfigTypesOK) readResponse(response runtime.ClientResponse, consum return nil } + +// NewListConfigTypesUnauthorized creates a ListConfigTypesUnauthorized with default headers values +func NewListConfigTypesUnauthorized() *ListConfigTypesUnauthorized { + return &ListConfigTypesUnauthorized{} +} + +/* ListConfigTypesUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListConfigTypesUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListConfigTypesUnauthorized) Error() string { + return fmt.Sprintf("[GET /config-types][%d] listConfigTypesUnauthorized %+v", 401, o.Payload) +} +func (o *ListConfigTypesUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListConfigTypesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_management_api_client/posture_checks/list_posture_check_types_responses.go b/rest_management_api_client/posture_checks/list_posture_check_types_responses.go index 498e78938..c872bb5d3 100644 --- a/rest_management_api_client/posture_checks/list_posture_check_types_responses.go +++ b/rest_management_api_client/posture_checks/list_posture_check_types_responses.go @@ -53,6 +53,12 @@ func (o *ListPostureCheckTypesReader) ReadResponse(response runtime.ClientRespon return nil, err } return result, nil + case 401: + result := NewListPostureCheckTypesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListPostureCheckTypesOK) readResponse(response runtime.ClientResponse, return nil } + +// NewListPostureCheckTypesUnauthorized creates a ListPostureCheckTypesUnauthorized with default headers values +func NewListPostureCheckTypesUnauthorized() *ListPostureCheckTypesUnauthorized { + return &ListPostureCheckTypesUnauthorized{} +} + +/* ListPostureCheckTypesUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListPostureCheckTypesUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListPostureCheckTypesUnauthorized) Error() string { + return fmt.Sprintf("[GET /posture-check-types][%d] listPostureCheckTypesUnauthorized %+v", 401, o.Payload) +} +func (o *ListPostureCheckTypesUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListPostureCheckTypesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_management_api_client/posture_checks/list_posture_checks_responses.go b/rest_management_api_client/posture_checks/list_posture_checks_responses.go index 2e7fd3c5e..78bcdf31f 100644 --- a/rest_management_api_client/posture_checks/list_posture_checks_responses.go +++ b/rest_management_api_client/posture_checks/list_posture_checks_responses.go @@ -53,6 +53,12 @@ func (o *ListPostureChecksReader) ReadResponse(response runtime.ClientResponse, return nil, err } return result, nil + case 401: + result := NewListPostureChecksUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result default: return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code()) } @@ -89,3 +95,35 @@ func (o *ListPostureChecksOK) readResponse(response runtime.ClientResponse, cons return nil } + +// NewListPostureChecksUnauthorized creates a ListPostureChecksUnauthorized with default headers values +func NewListPostureChecksUnauthorized() *ListPostureChecksUnauthorized { + return &ListPostureChecksUnauthorized{} +} + +/* ListPostureChecksUnauthorized describes a response with status code 401, with default header values. + +The currently supplied session does not have the correct access rights to request this resource +*/ +type ListPostureChecksUnauthorized struct { + Payload *rest_model.APIErrorEnvelope +} + +func (o *ListPostureChecksUnauthorized) Error() string { + return fmt.Sprintf("[GET /posture-checks][%d] listPostureChecksUnauthorized %+v", 401, o.Payload) +} +func (o *ListPostureChecksUnauthorized) GetPayload() *rest_model.APIErrorEnvelope { + return o.Payload +} + +func (o *ListPostureChecksUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(rest_model.APIErrorEnvelope) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/rest_management_api_server/embedded_spec.go b/rest_management_api_server/embedded_spec.go index a76e8be4d..21ec05607 100644 --- a/rest_management_api_server/embedded_spec.go +++ b/rest_management_api_server/embedded_spec.go @@ -117,6 +117,30 @@ func init() { "schema": { "$ref": "#/definitions/listApiSessionsEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } } @@ -1023,6 +1047,30 @@ func init() { "schema": { "$ref": "#/definitions/listCasEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -1779,6 +1827,30 @@ func init() { "schema": { "$ref": "#/definitions/listConfigTypesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -8085,6 +8157,30 @@ func init() { "schema": { "$ref": "#/definitions/listPostureCheckTypesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } } @@ -8224,6 +8320,30 @@ func init() { "schema": { "$ref": "#/definitions/listPostureCheckEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -14244,7 +14364,8 @@ func init() { "isAutoCaEnrollmentEnabled", "isOttCaEnrollmentEnabled", "isAuthEnabled", - "identityRoles" + "identityRoles", + "identityNameFormat" ], "properties": { "identityNameFormat": { @@ -18851,6 +18972,30 @@ func init() { "schema": { "$ref": "#/definitions/listApiSessionsEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } } @@ -19757,6 +19902,30 @@ func init() { "schema": { "$ref": "#/definitions/listCasEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -20513,6 +20682,30 @@ func init() { "schema": { "$ref": "#/definitions/listConfigTypesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -26819,6 +27012,30 @@ func init() { "schema": { "$ref": "#/definitions/listPostureCheckTypesEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } } @@ -26958,6 +27175,30 @@ func init() { "schema": { "$ref": "#/definitions/listPostureCheckEnvelope" } + }, + "401": { + "description": "The currently supplied session does not have the correct access rights to request this resource", + "schema": { + "$ref": "#/definitions/apiErrorEnvelope" + }, + "examples": { + "application/json": { + "error": { + "args": { + "urlVars": {} + }, + "cause": "", + "causeMessage": "", + "code": "UNAUTHORIZED", + "message": "The request could not be completed. The session is not authorized or the credentials are invalid", + "requestId": "0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f" + }, + "meta": { + "apiEnrolmentVersion": "0.0.1", + "apiVersion": "0.0.1" + } + } + } } } }, @@ -33068,7 +33309,8 @@ func init() { "isAutoCaEnrollmentEnabled", "isOttCaEnrollmentEnabled", "isAuthEnabled", - "identityRoles" + "identityRoles", + "identityNameFormat" ], "properties": { "identityNameFormat": { diff --git a/rest_management_api_server/operations/api_session/list_api_sessions_responses.go b/rest_management_api_server/operations/api_session/list_api_sessions_responses.go index 76c103519..b86a7b275 100644 --- a/rest_management_api_server/operations/api_session/list_api_sessions_responses.go +++ b/rest_management_api_server/operations/api_session/list_api_sessions_responses.go @@ -80,3 +80,47 @@ func (o *ListAPISessionsOK) WriteResponse(rw http.ResponseWriter, producer runti } } } + +// ListAPISessionsUnauthorizedCode is the HTTP code returned for type ListAPISessionsUnauthorized +const ListAPISessionsUnauthorizedCode int = 401 + +/*ListAPISessionsUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listApiSessionsUnauthorized +*/ +type ListAPISessionsUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListAPISessionsUnauthorized creates ListAPISessionsUnauthorized with default headers values +func NewListAPISessionsUnauthorized() *ListAPISessionsUnauthorized { + + return &ListAPISessionsUnauthorized{} +} + +// WithPayload adds the payload to the list Api sessions unauthorized response +func (o *ListAPISessionsUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListAPISessionsUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list Api sessions unauthorized response +func (o *ListAPISessionsUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListAPISessionsUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_management_api_server/operations/certificate_authority/list_cas_responses.go b/rest_management_api_server/operations/certificate_authority/list_cas_responses.go index 9e21826f3..7d254e9fb 100644 --- a/rest_management_api_server/operations/certificate_authority/list_cas_responses.go +++ b/rest_management_api_server/operations/certificate_authority/list_cas_responses.go @@ -80,3 +80,47 @@ func (o *ListCasOK) WriteResponse(rw http.ResponseWriter, producer runtime.Produ } } } + +// ListCasUnauthorizedCode is the HTTP code returned for type ListCasUnauthorized +const ListCasUnauthorizedCode int = 401 + +/*ListCasUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listCasUnauthorized +*/ +type ListCasUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListCasUnauthorized creates ListCasUnauthorized with default headers values +func NewListCasUnauthorized() *ListCasUnauthorized { + + return &ListCasUnauthorized{} +} + +// WithPayload adds the payload to the list cas unauthorized response +func (o *ListCasUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListCasUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list cas unauthorized response +func (o *ListCasUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListCasUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_management_api_server/operations/config/list_config_types_responses.go b/rest_management_api_server/operations/config/list_config_types_responses.go index f70611d84..02d344ed6 100644 --- a/rest_management_api_server/operations/config/list_config_types_responses.go +++ b/rest_management_api_server/operations/config/list_config_types_responses.go @@ -80,3 +80,47 @@ func (o *ListConfigTypesOK) WriteResponse(rw http.ResponseWriter, producer runti } } } + +// ListConfigTypesUnauthorizedCode is the HTTP code returned for type ListConfigTypesUnauthorized +const ListConfigTypesUnauthorizedCode int = 401 + +/*ListConfigTypesUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listConfigTypesUnauthorized +*/ +type ListConfigTypesUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListConfigTypesUnauthorized creates ListConfigTypesUnauthorized with default headers values +func NewListConfigTypesUnauthorized() *ListConfigTypesUnauthorized { + + return &ListConfigTypesUnauthorized{} +} + +// WithPayload adds the payload to the list config types unauthorized response +func (o *ListConfigTypesUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListConfigTypesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list config types unauthorized response +func (o *ListConfigTypesUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListConfigTypesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_management_api_server/operations/posture_checks/list_posture_check_types_responses.go b/rest_management_api_server/operations/posture_checks/list_posture_check_types_responses.go index 7b897c8ec..4f1c69b41 100644 --- a/rest_management_api_server/operations/posture_checks/list_posture_check_types_responses.go +++ b/rest_management_api_server/operations/posture_checks/list_posture_check_types_responses.go @@ -80,3 +80,47 @@ func (o *ListPostureCheckTypesOK) WriteResponse(rw http.ResponseWriter, producer } } } + +// ListPostureCheckTypesUnauthorizedCode is the HTTP code returned for type ListPostureCheckTypesUnauthorized +const ListPostureCheckTypesUnauthorizedCode int = 401 + +/*ListPostureCheckTypesUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listPostureCheckTypesUnauthorized +*/ +type ListPostureCheckTypesUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListPostureCheckTypesUnauthorized creates ListPostureCheckTypesUnauthorized with default headers values +func NewListPostureCheckTypesUnauthorized() *ListPostureCheckTypesUnauthorized { + + return &ListPostureCheckTypesUnauthorized{} +} + +// WithPayload adds the payload to the list posture check types unauthorized response +func (o *ListPostureCheckTypesUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListPostureCheckTypesUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list posture check types unauthorized response +func (o *ListPostureCheckTypesUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPostureCheckTypesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_management_api_server/operations/posture_checks/list_posture_checks_responses.go b/rest_management_api_server/operations/posture_checks/list_posture_checks_responses.go index aa5b358f5..843db774f 100644 --- a/rest_management_api_server/operations/posture_checks/list_posture_checks_responses.go +++ b/rest_management_api_server/operations/posture_checks/list_posture_checks_responses.go @@ -80,3 +80,47 @@ func (o *ListPostureChecksOK) WriteResponse(rw http.ResponseWriter, producer run } } } + +// ListPostureChecksUnauthorizedCode is the HTTP code returned for type ListPostureChecksUnauthorized +const ListPostureChecksUnauthorizedCode int = 401 + +/*ListPostureChecksUnauthorized The currently supplied session does not have the correct access rights to request this resource + +swagger:response listPostureChecksUnauthorized +*/ +type ListPostureChecksUnauthorized struct { + + /* + In: Body + */ + Payload *rest_model.APIErrorEnvelope `json:"body,omitempty"` +} + +// NewListPostureChecksUnauthorized creates ListPostureChecksUnauthorized with default headers values +func NewListPostureChecksUnauthorized() *ListPostureChecksUnauthorized { + + return &ListPostureChecksUnauthorized{} +} + +// WithPayload adds the payload to the list posture checks unauthorized response +func (o *ListPostureChecksUnauthorized) WithPayload(payload *rest_model.APIErrorEnvelope) *ListPostureChecksUnauthorized { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the list posture checks unauthorized response +func (o *ListPostureChecksUnauthorized) SetPayload(payload *rest_model.APIErrorEnvelope) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *ListPostureChecksUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(401) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/rest_model/ca_update.go b/rest_model/ca_update.go index 495b537fb..cc787353c 100644 --- a/rest_model/ca_update.go +++ b/rest_model/ca_update.go @@ -44,7 +44,8 @@ import ( type CaUpdate struct { // identity name format - IdentityNameFormat string `json:"identityNameFormat,omitempty"` + // Required: true + IdentityNameFormat *string `json:"identityNameFormat"` // identity roles // Required: true @@ -78,6 +79,10 @@ type CaUpdate struct { func (m *CaUpdate) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateIdentityNameFormat(formats); err != nil { + res = append(res, err) + } + if err := m.validateIdentityRoles(formats); err != nil { res = append(res, err) } @@ -108,6 +113,15 @@ func (m *CaUpdate) Validate(formats strfmt.Registry) error { return nil } +func (m *CaUpdate) validateIdentityNameFormat(formats strfmt.Registry) error { + + if err := validate.Required("identityNameFormat", "body", m.IdentityNameFormat); err != nil { + return err + } + + return nil +} + func (m *CaUpdate) validateIdentityRoles(formats strfmt.Registry) error { if err := validate.Required("identityRoles", "body", m.IdentityRoles); err != nil { diff --git a/specs/client.yml b/specs/client.yml index 5d93c6634..073b491b4 100644 --- a/specs/client.yml +++ b/specs/client.yml @@ -347,6 +347,25 @@ paths: description: A list of the current API Session's certificate schema: $ref: '#/definitions/listCurrentApiSessionCertificatesEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 post: security: - ztSession: [] diff --git a/specs/management.yml b/specs/management.yml index 52690e75a..ad8313acb 100644 --- a/specs/management.yml +++ b/specs/management.yml @@ -52,6 +52,25 @@ paths: description: A list of active API Sessions schema: $ref: '#/definitions/listApiSessionsEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 /api-sessions/{id}: get: security: @@ -701,6 +720,25 @@ paths: description: A list of Certificate Authorities (CAs) schema: $ref: '#/definitions/listCasEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 post: security: - ztSession: [] @@ -1256,6 +1294,25 @@ paths: description: A list of config-types schema: $ref: '#/definitions/listConfigTypesEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 post: security: - ztSession: [] @@ -5800,6 +5857,25 @@ paths: description: A list of posture check types schema: $ref: '#/definitions/listPostureCheckTypesEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 /posture-check-types/{id}: get: security: @@ -5893,6 +5969,25 @@ paths: description: A list of posture checks schema: $ref: '#/definitions/listPostureCheckEnvelope' + "401": + description: The currently supplied session does not have the correct access + rights to request this resource + schema: + $ref: '#/definitions/apiErrorEnvelope' + examples: + application/json: + error: + args: + urlVars: {} + cause: "" + causeMessage: "" + code: UNAUTHORIZED + message: The request could not be completed. The session is not authorized + or the credentials are invalid + requestId: 0bfe7a04-9229-4b7a-812c-9eb3cc0eac0f + meta: + apiEnrolmentVersion: 0.0.1 + apiVersion: 0.0.1 post: security: - ztSession: [] @@ -10220,6 +10315,7 @@ definitions: - isOttCaEnrollmentEnabled - isAuthEnabled - identityRoles + - identityNameFormat properties: identityNameFormat: type: string diff --git a/specs/source/client/current-api-session-certificates.yml b/specs/source/client/current-api-session-certificates.yml index 5952808a2..ec99fb86d 100644 --- a/specs/source/client/current-api-session-certificates.yml +++ b/specs/source/client/current-api-session-certificates.yml @@ -16,6 +16,8 @@ paths: responses: '200': $ref: '#/responses/listCurrentApiSessionCertificates' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' post: summary: Creates an ephemeral certificate for the current API Session description: Creates an ephemeral certificate for the current API Session. This endpoint diff --git a/specs/source/management/api-sessions.yml b/specs/source/management/api-sessions.yml index b38c72937..5b7cf1c0d 100644 --- a/specs/source/management/api-sessions.yml +++ b/specs/source/management/api-sessions.yml @@ -21,6 +21,8 @@ paths: responses: '200': $ref: '#/responses/listAPISessions' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' api-sessions-id: parameters: - $ref: '../shared/parameters.yml#/id' diff --git a/specs/source/management/cas.yml b/specs/source/management/cas.yml index 22a04deaa..c1b126061 100644 --- a/specs/source/management/cas.yml +++ b/specs/source/management/cas.yml @@ -16,6 +16,8 @@ paths: responses: '200': $ref: '#/responses/listCas' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' post: summary: Creates a CA description: Creates a CA in an unverified state. Requires admin access. @@ -317,6 +319,7 @@ definitions: - isOttCaEnrollmentEnabled - isAuthEnabled - identityRoles + - identityNameFormat properties: name: type: string diff --git a/specs/source/management/config-types.yml b/specs/source/management/config-types.yml index e2aaa7278..09dc84ee1 100644 --- a/specs/source/management/config-types.yml +++ b/specs/source/management/config-types.yml @@ -17,6 +17,8 @@ paths: responses: '200': $ref: '#/responses/listConfigTypes' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' post: summary: Create a config-type. Requires admin access. security: diff --git a/specs/source/management/posture-check-types.yml b/specs/source/management/posture-check-types.yml index 88544d24a..71e335616 100644 --- a/specs/source/management/posture-check-types.yml +++ b/specs/source/management/posture-check-types.yml @@ -19,6 +19,8 @@ paths: responses: '200': $ref: '#/responses/listPostureCheckTypes' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' posture-check-types-id: parameters: - $ref: '../shared/parameters.yml#/id' diff --git a/specs/source/management/posture-checks.yml b/specs/source/management/posture-checks.yml index e6b8d820d..0d2a4c077 100644 --- a/specs/source/management/posture-checks.yml +++ b/specs/source/management/posture-checks.yml @@ -21,6 +21,8 @@ paths: responses: '200': $ref: '#/responses/listPostureChecks' + '401': + $ref: '../shared/standard-responses.yml#/responses/unauthorizedResponse' post: summary: Creates a Posture Checks description: Creates a Posture Checks diff --git a/tests/ca_test.go b/tests/ca_test.go index 39fb84171..c557517b7 100644 --- a/tests/ca_test.go +++ b/tests/ca_test.go @@ -41,6 +41,18 @@ func Test_CA(t *testing.T) { ctx.AdminManagementSession.validateEntityWithLookup(ca) }) + t.Run("identityNameFormat should be updated", func(t *testing.T) { + ctx.testContextChanged(t) + role1 := eid.New() + role2 := eid.New() + ca := newTestCa(role1, role2) + ca.id = ctx.AdminManagementSession.requireCreateEntity(ca) + + ca.identityNameFormat = "123" + ctx.AdminManagementSession.requireUpdateEntity(ca) + ctx.AdminManagementSession.validateEntityWithLookup(ca) + }) + t.Run("identity name format should default if not specified", func(t *testing.T) { ctx.testContextChanged(t) role1 := eid.New()