Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

CERT-22 - Add CSR feature#53

Merged
dborovcanin merged 10 commits into
absmach:mainfrom
nyagamunene:Add-CSR
Nov 28, 2024
Merged

CERT-22 - Add CSR feature#53
dborovcanin merged 10 commits into
absmach:mainfrom
nyagamunene:Add-CSR

Conversation

@nyagamunene

Copy link
Copy Markdown
Contributor

What type of PR is this?

What does this do?

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Yes.

Did you document any new/modified features?

Yes

Notes

@dborovcanin

Copy link
Copy Markdown
Contributor

@nyagamunene What's the status with this one?

@nyagamunene

Copy link
Copy Markdown
Contributor Author

@nyagamunene What's the status with this one?

There is still some issues with tests which am currently addressing.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@nyagamunene nyagamunene marked this pull request as ready for review November 27, 2024 23:50
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Comment thread api/http/endpoint.go Outdated
}
}

func retrieveCSREndpoint(svc certs.Service) endpoint.Endpoint {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Switch the order of retrieve and list endpoints.

Comment thread api/http/transport.go Outdated
EncodeResponse,
opts...,
), "").ServeHTTP)
r.Get("/list", otelhttp.NewHandler(kithttp.NewServer(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no need for /list, an empty route will work.

Comment thread api/http/transport.go Outdated
encodeCADownloadResponse,
opts...,
), "download_ca").ServeHTTP)
r.Route("/csr", func(r chi.Router) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use plural, csrs.

Comment thread api/metrics.go Outdated

func (mm *metricsMiddleware) SignCSR(ctx context.Context, csrID string, approve bool) error {
defer func(begin time.Time) {
mm.counter.With("method", "process_csr").Add(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mm.counter.With("method", "sign_csr").Add(1)

Comment thread api/metrics.go Outdated
func (mm *metricsMiddleware) SignCSR(ctx context.Context, csrID string, approve bool) error {
defer func(begin time.Time) {
mm.counter.With("method", "process_csr").Add(1)
mm.latency.With("method", "process_csr").Observe(time.Since(begin).Seconds())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same.

Comment thread certs.go Outdated
Comment on lines +243 to +247
// ListCSRs returns a list of CSRs based on filter criteria
ListCSRs(ctx context.Context, pm PageMetadata) (CSRPage, error)

// RetrieveCSR retrieves a specific CSR by ID
RetrieveCSR(ctx context.Context, csrID string) (CSR, error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same, swap the order.

Comment thread postgres/csr/init.go Outdated
{
Id: "csr_1",
Up: []string{
`CREATE TABLE IF NOT EXISTS csr (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Double-check if this is aligned properly.

Comment thread sdk/sdk.go Outdated
Comment on lines +294 to +304
// ListCSRs returns a list of CSRs based on filter criteria
//
// response, _ := sdk.ListCSRs(sdk.PageMetadata{EntityID: "entity_id", Status: "pending"})
// fmt.Println(response)
ListCSRs(pm PageMetadata) (CSRPage, errors.SDKError)

// RetrieveCSR retrieves a specific CSR by ID
//
// response, _ := sdk.RetrieveCSR("csr_id")
// fmt.Println(response)
RetrieveCSR(csrID string) (CSR, errors.SDKError)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same order remark.

Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
Signed-off-by: nyagamunene <stevenyaga2014@gmail.com>
@dborovcanin dborovcanin merged commit f2b8a9a into absmach:main Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Feature: Add CSR feature

2 participants