Skip to content

Commit

Permalink
fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Sep 19, 2024
1 parent 00b30d5 commit 3c25757
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/k8s/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.6
require (
dario.cat/mergo v1.0.0
github.com/canonical/go-dqlite v1.22.0
github.com/canonical/k8s-snap-api v1.0.5
github.com/canonical/k8s-snap-api v1.0.7
github.com/canonical/lxd v0.0.0-20240822122218-e7b2a7a83230
github.com/canonical/microcluster/v3 v3.0.0-20240827143335-f7a4d3984970
github.com/go-logr/logr v1.4.2
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXe
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/canonical/go-dqlite v1.22.0 h1:DuJmfcREl4gkQJyvZzjl2GHFZROhbPyfdjDRQXpkOyw=
github.com/canonical/go-dqlite v1.22.0/go.mod h1:Uvy943N8R4CFUAs59A1NVaziWY9nJ686lScY7ywurfg=
github.com/canonical/k8s-snap-api v1.0.5 h1:49bgi6CGtFjCPweeTz55Sv/waKgCl6ftx4BqXt3RI9k=
github.com/canonical/k8s-snap-api v1.0.5/go.mod h1:LDPoIYCeYnfgOFrwVPJ/4edGU264w7BB7g0GsVi36AY=
github.com/canonical/k8s-snap-api v1.0.7 h1:40qz+9IcV90ZN/wTMuOraZcuqoyRHaJck1J3c7FcWrQ=
github.com/canonical/k8s-snap-api v1.0.7/go.mod h1:LDPoIYCeYnfgOFrwVPJ/4edGU264w7BB7g0GsVi36AY=
github.com/canonical/lxd v0.0.0-20240822122218-e7b2a7a83230 h1:YOqZ+/14OPZ+/TOXpRHIX3KLT0C+wZVpewKIwlGUmW0=
github.com/canonical/lxd v0.0.0-20240822122218-e7b2a7a83230/go.mod h1:YVGI7HStOKsV+cMyXWnJ7RaMPaeWtrkxyIPvGWbgACc=
github.com/canonical/microcluster/v3 v3.0.0-20240827143335-f7a4d3984970 h1:UrnpglbXELlxtufdk6DGDytu2JzyzuS3WTsOwPrkQLI=
Expand Down
14 changes: 4 additions & 10 deletions src/k8s/pkg/k8sd/api/capi_certificates_expiry.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
package api

import (
"encoding/json"
"fmt"
"net/http"
"time"

apiv1 "github.com/canonical/k8s-snap-api/api/v1"
"github.com/canonical/k8s/pkg/k8sd/database"
databaseutil "github.com/canonical/k8s/pkg/k8sd/database/util"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/v3/state"
)

func (e *Endpoints) postCertificatesExpiry(s state.State, r *http.Request) response.Response {
request := apiv1.ClusterAPICertificatesExpiryRequest{}
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
return response.BadRequest(fmt.Errorf("failed to parse request: %w", err))
}

config, err := database.GetClusterConfig(r.Context(), s)
config, err := databaseutil.GetClusterConfig(r.Context(), s)
if err != nil {
return response.InternalError(fmt.Errorf("failed to get cluster config: %w", err))
}
Expand Down Expand Up @@ -50,7 +44,7 @@ func (e *Endpoints) postCertificatesExpiry(s state.State, r *http.Request) respo
}
}

return response.SyncResponse(true, &apiv1.ClusterAPICertificatesExpiryResponse{
Expiry: earliestExpiry.Format(time.RFC3339),
return response.SyncResponse(true, &apiv1.CertificatesExpiryResponse{
ExpiryDate: earliestExpiry.Format(time.RFC3339),
})
}
2 changes: 1 addition & 1 deletion tests/integration/tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_smoke(instances: List[harness.Instance]):
metadata is not None
), "Metadata not found in the certificate expiry response."
assert util.is_valid_rfc3339(
metadata.get("expiry")
metadata.get("expiry-date")
), "Token not found in the certificate expiry response."

def status_output_matches(p: subprocess.CompletedProcess) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/test_util/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Copyright 2024 Canonical, Ltd.
#
import datetime
from datetime import datetime
import json
import logging
import re
Expand Down

0 comments on commit 3c25757

Please sign in to comment.