Skip to content

Commit cbd36c4

Browse files
committed
build(deps): pin the api to main, which carries the time-sync contract
api main also declares the SCEP and TSA RPCs, which this node does not serve yet. internal/grpc/unserved.go answers them Unimplemented. It is byte for byte the file the protocol-switches change adds, so rebasing onto that change merges it cleanly. Signed-off-by: Bugs5382 <12115015+Bugs5382@users.noreply.github.com>
1 parent e47957b commit cbd36c4

4 files changed

Lines changed: 145 additions & 3 deletions

File tree

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/CryptOS-PKI/cryptos
33
go 1.25.0
44

55
require (
6-
github.com/CryptOS-PKI/api v0.0.0-20260929205700-cc4308e5886b
6+
github.com/CryptOS-PKI/api v0.0.0-20260930142054-81494db99991
77
github.com/google/go-tpm v0.9.8
88
github.com/google/go-tpm-tools v0.4.8
99
github.com/spf13/cobra v1.10.2

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/CryptOS-PKI/api v0.0.0-20260929205700-cc4308e5886b h1:8IJpCxaCfWAQ0QddBz/CtolWOBDqA/5U7E9k6QbLDzU=
2-
github.com/CryptOS-PKI/api v0.0.0-20260929205700-cc4308e5886b/go.mod h1:tmeaYhNoUblqPYYNtTbGBGIUsZ7xLATgLdKq4S33rmE=
1+
github.com/CryptOS-PKI/api v0.0.0-20260930142054-81494db99991 h1:gRd3iY+smHPGl98k/T9Ezc9wG9/8hh+kJ8eZoGOOkW8=
2+
github.com/CryptOS-PKI/api v0.0.0-20260930142054-81494db99991/go.mod h1:tmeaYhNoUblqPYYNtTbGBGIUsZ7xLATgLdKq4S33rmE=
33
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
44
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
55
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=

‎internal/grpc/unserved.go‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package grpc
2+
3+
/*
4+
Apache License 2.0
5+
6+
Copyright 2026 Shane
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
*/
20+
21+
import (
22+
"context"
23+
24+
"google.golang.org/grpc/codes"
25+
"google.golang.org/grpc/status"
26+
27+
cryptosv1 "github.com/CryptOS-PKI/api/go/cryptos/v1"
28+
)
29+
30+
// The SCEP and RFC 3161 TSA RPCs are in the api contract, but this build does
31+
// not serve either protocol yet. Each answers Unimplemented until its server
32+
// lands and replaces the stub here.
33+
34+
func (s *Server) MintScepChallenge(context.Context, *cryptosv1.MintScepChallengeRequest) (*cryptosv1.MintScepChallengeResponse, error) {
35+
return nil, errSCEPUnserved
36+
}
37+
38+
func (s *Server) ListScepChallenges(context.Context, *cryptosv1.ListScepChallengesRequest) (*cryptosv1.ListScepChallengesResponse, error) {
39+
return nil, errSCEPUnserved
40+
}
41+
42+
func (s *Server) RevokeScepChallenge(context.Context, *cryptosv1.RevokeScepChallengeRequest) (*cryptosv1.RevokeScepChallengeResponse, error) {
43+
return nil, errSCEPUnserved
44+
}
45+
46+
func (s *Server) ListScepEnrollments(context.Context, *cryptosv1.ListScepEnrollmentsRequest) (*cryptosv1.ListScepEnrollmentsResponse, error) {
47+
return nil, errSCEPUnserved
48+
}
49+
50+
func (s *Server) ApproveScepEnrollment(context.Context, *cryptosv1.ApproveScepEnrollmentRequest) (*cryptosv1.ApproveScepEnrollmentResponse, error) {
51+
return nil, errSCEPUnserved
52+
}
53+
54+
func (s *Server) RejectScepEnrollment(context.Context, *cryptosv1.RejectScepEnrollmentRequest) (*cryptosv1.RejectScepEnrollmentResponse, error) {
55+
return nil, errSCEPUnserved
56+
}
57+
58+
func (s *Server) ListTsaCertificates(context.Context, *cryptosv1.ListTsaCertificatesRequest) (*cryptosv1.ListTsaCertificatesResponse, error) {
59+
return nil, status.Error(codes.Unimplemented, "the RFC 3161 time-stamp authority is not served by this build")
60+
}
61+
62+
var errSCEPUnserved = status.Error(codes.Unimplemented, "SCEP is not served by this build")

‎internal/grpc/unserved_test.go‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package grpc
2+
3+
/*
4+
Apache License 2.0
5+
6+
Copyright 2026 Shane
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
*/
20+
21+
import (
22+
"context"
23+
"testing"
24+
25+
"google.golang.org/grpc/codes"
26+
"google.golang.org/grpc/status"
27+
28+
cryptosv1 "github.com/CryptOS-PKI/api/go/cryptos/v1"
29+
)
30+
31+
// TestUnservedRPCs_ReturnUnimplemented pins the answer for the NodeService
32+
// RPCs in the api contract that this build does not serve yet: Unimplemented,
33+
// never a panic or a silent empty success.
34+
func TestUnservedRPCs_ReturnUnimplemented(t *testing.T) {
35+
srv, err := New(ServerConfig{
36+
TLSConfig: newFixtures(t).serverConf,
37+
Auditor: &mockAuditor{},
38+
})
39+
if err != nil {
40+
t.Fatalf("New: %v", err)
41+
}
42+
ctx := context.Background()
43+
calls := map[string]func() error{
44+
"MintScepChallenge": func() error {
45+
_, err := srv.MintScepChallenge(ctx, &cryptosv1.MintScepChallengeRequest{})
46+
return err
47+
},
48+
"ListScepChallenges": func() error {
49+
_, err := srv.ListScepChallenges(ctx, &cryptosv1.ListScepChallengesRequest{})
50+
return err
51+
},
52+
"RevokeScepChallenge": func() error {
53+
_, err := srv.RevokeScepChallenge(ctx, &cryptosv1.RevokeScepChallengeRequest{})
54+
return err
55+
},
56+
"ListScepEnrollments": func() error {
57+
_, err := srv.ListScepEnrollments(ctx, &cryptosv1.ListScepEnrollmentsRequest{})
58+
return err
59+
},
60+
"ApproveScepEnrollment": func() error {
61+
_, err := srv.ApproveScepEnrollment(ctx, &cryptosv1.ApproveScepEnrollmentRequest{})
62+
return err
63+
},
64+
"RejectScepEnrollment": func() error {
65+
_, err := srv.RejectScepEnrollment(ctx, &cryptosv1.RejectScepEnrollmentRequest{})
66+
return err
67+
},
68+
"ListTsaCertificates": func() error {
69+
_, err := srv.ListTsaCertificates(ctx, &cryptosv1.ListTsaCertificatesRequest{})
70+
return err
71+
},
72+
}
73+
for name, call := range calls {
74+
t.Run(name, func(t *testing.T) {
75+
if got := status.Code(call()); got != codes.Unimplemented {
76+
t.Errorf("%s code = %v, want Unimplemented", name, got)
77+
}
78+
})
79+
}
80+
}

0 commit comments

Comments
 (0)