Skip to content

Commit aa825c4

Browse files
authored
Fix hiba_authentication, host_certificate test for Nokia (openconfig#5267)
* Fix hiba_authentication, host_certificate test for Nokia * Fixed static errors
1 parent 7e93ffd commit aa825c4

File tree

7 files changed

+1937
-480
lines changed

7 files changed

+1937
-480
lines changed

feature/gnsi/credentialz/tests/hiba_authentication/hiba_authentication_test.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ import (
3131
)
3232

3333
const (
34-
username = "testuser"
35-
maxSSHRetryTime = 30 // Unit is seconds.
34+
username = "testuser"
35+
maxSSHRetryTime = 30 // Unit is seconds.
36+
hostCertificateVersion = "v1.0"
3637
)
3738

3839
var (
3940
hostCertificateCreatedOn = time.Now().Unix()
40-
hostCertificateVersion = credz.GenerateVersion()
4141
)
4242

4343
func TestMain(m *testing.M) {
@@ -134,21 +134,23 @@ func TestCredentialz(t *testing.T) {
134134
}
135135

136136
// Verify host certificate telemetry.
137-
sshServer := gnmi.Get(t, dut, gnmi.OC().System().SshServer().State())
138-
gotHostCertificateVersion := sshServer.GetActiveHostCertificateVersion()
139-
if !cmp.Equal(gotHostCertificateVersion, hostCertificateVersion) {
140-
t.Fatalf(
141-
"Telemetry reports host certificate version is not correct\n\tgot: %s\n\twant: %s",
142-
gotHostCertificateVersion, hostCertificateVersion,
143-
)
144-
}
145-
gotHostCertificateCreatedOn := sshServer.GetActiveHostCertificateCreatedOn()
146-
// if !cmp.Equal(time.Unix(0, int64(gotHostCertificateCreatedOn)), time.Unix(hostCertificateCreatedOn, 0)) {
147-
if !cmp.Equal(time.Unix(int64(gotHostCertificateCreatedOn), 0), time.Unix(hostCertificateCreatedOn, 0)) {
148-
t.Fatalf(
149-
"Telemetry reports host certificate created on is not correct\n\tgot: %d\n\twant: %d",
150-
gotHostCertificateCreatedOn, hostCertificateCreatedOn,
151-
)
137+
if !deviations.SSHServerHostCertificateTelemetryUnsupported(dut) {
138+
sshServer := gnmi.Get(t, dut, gnmi.OC().System().SshServer().State())
139+
gotHostCertificateVersion := sshServer.GetActiveHostCertificateVersion()
140+
if !cmp.Equal(gotHostCertificateVersion, hostCertificateVersion) {
141+
t.Fatalf(
142+
"Telemetry reports host certificate version is not correct\n\tgot: %s\n\twant: %s",
143+
gotHostCertificateVersion, hostCertificateVersion,
144+
)
145+
}
146+
gotHostCertificateCreatedOn := sshServer.GetActiveHostCertificateCreatedOn()
147+
// if !cmp.Equal(time.Unix(0, int64(gotHostCertificateCreatedOn)), time.Unix(hostCertificateCreatedOn, 0)) {
148+
if !cmp.Equal(time.Unix(int64(gotHostCertificateCreatedOn), 0), time.Unix(hostCertificateCreatedOn, 0)) {
149+
t.Fatalf(
150+
"Telemetry reports host certificate created on is not correct\n\tgot: %d\n\twant: %d",
151+
gotHostCertificateCreatedOn, hostCertificateCreatedOn,
152+
)
153+
}
152154
}
153155
})
154156

feature/gnsi/credentialz/tests/hiba_authentication/metadata.textproto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ platform_exceptions: {
1111
}
1212
deviations: {
1313
ssh_server_counters_unsupported: true
14+
ssh_server_host_certificate_telemetry_unsupported: true
1415
}
1516
}
1617

feature/gnsi/credentialz/tests/host_certificates/host_certificates_test.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
"time"
2323

2424
"github.com/google/go-cmp/cmp"
25-
"github.com/openconfig/ondatra/gnmi"
26-
2725
"github.com/openconfig/featureprofiles/internal/args"
26+
"github.com/openconfig/featureprofiles/internal/deviations"
2827
"github.com/openconfig/featureprofiles/internal/fptest"
2928
"github.com/openconfig/featureprofiles/internal/security/credz"
3029
"github.com/openconfig/ondatra"
30+
"github.com/openconfig/ondatra/gnmi"
3131
"golang.org/x/crypto/ssh"
3232
)
3333

@@ -92,20 +92,22 @@ func TestCredentialz(t *testing.T) {
9292
}
9393

9494
// Verify host certificate telemetry values.
95-
sshServer := gnmi.Get(t, dut, gnmi.OC().System().SshServer().State())
96-
gotHostCertificateVersion := sshServer.GetActiveHostCertificateVersion()
97-
if !cmp.Equal(gotHostCertificateVersion, hostCertificateVersion) {
98-
t.Errorf(
99-
"Telemetry reports host certificate version is not correct\n\tgot: %s\n\twant: %s",
100-
gotHostCertificateVersion, hostCertificateVersion,
101-
)
102-
}
103-
gotHostCertificateCreatedOn := sshServer.GetActiveHostCertificateCreatedOn()
104-
if got, want := gotHostCertificateCreatedOn, hostCertificateCreatedOn; got != want {
105-
t.Errorf(
106-
"Telemetry reports host certificate created on is not correct\n\twant: %d\n\tgot: %d",
107-
want, got,
108-
)
95+
if !deviations.SSHServerHostCertificateTelemetryUnsupported(dut) {
96+
sshServer := gnmi.Get(t, dut, gnmi.OC().System().SshServer().State())
97+
gotHostCertificateVersion := sshServer.GetActiveHostCertificateVersion()
98+
if !cmp.Equal(gotHostCertificateVersion, hostCertificateVersion) {
99+
t.Errorf(
100+
"Telemetry reports host certificate version is not correct\n\tgot: %s\n\twant: %s",
101+
gotHostCertificateVersion, hostCertificateVersion,
102+
)
103+
}
104+
gotHostCertificateCreatedOn := sshServer.GetActiveHostCertificateCreatedOn()
105+
if got, want := gotHostCertificateCreatedOn, hostCertificateCreatedOn; got != want {
106+
t.Errorf(
107+
"Telemetry reports host certificate created on is not correct\n\twant: %d\n\tgot: %d",
108+
want, got,
109+
)
110+
}
109111
}
110112
})
111113
}

feature/gnsi/credentialz/tests/host_certificates/metadata.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ uuid: "91120b0a-91ea-493c-8046-f52176ec2029"
55
plan_id: "Credentialz-3"
66
description: "Host Certificates"
77
testbed: TESTBED_DUT
8+
platform_exceptions: {
9+
platform: {
10+
vendor: NOKIA
11+
}
12+
deviations: {
13+
ssh_server_host_certificate_telemetry_unsupported: true
14+
}
15+
}

internal/deviations/deviations.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,3 +2011,10 @@ func ArpFT(dut *ondatra.DUTDevice) string {
20112011
func PrefixLimitConfigUnsupported(dut *ondatra.DUTDevice) bool {
20122012
return lookupDUTDeviations(dut).GetPrefixLimitConfigUnsupported()
20132013
}
2014+
2015+
// SSHServerHostCertificateTelemetryUnsupported returns true if /system/ssh-server/state/active-host-certificate-version
2016+
// is not supported.
2017+
// Nokia: https://partnerissuetracker.corp.google.com/issues/494777653
2018+
func SSHServerHostCertificateTelemetryUnsupported(dut *ondatra.DUTDevice) bool {
2019+
return lookupDUTDeviations(dut).GetSshServerHostCertificateTelemetryUnsupported()
2020+
}

proto/metadata.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,13 @@ message Metadata {
12071207
// Device does not support configuring prefix limit received paths through OC
12081208
// Cisco: https://partnerissuetracker.corp.google.com/issues/447509237
12091209
bool prefix_limit_config_unsupported = 393;
1210+
1211+
// SSHServerHostCertificateTelemetryUnsupported returns true if /system/ssh-server/state/active-host-certificate-version
1212+
// is not supported.
1213+
// Nokia: https://partnerissuetracker.corp.google.com/issues/494777653
1214+
bool ssh_server_host_certificate_telemetry_unsupported = 394;
12101215

1216+
12111217
// Reserved field numbers and identifiers.
12121218
reserved 84, 9, 28, 20, 38, 43, 90, 97, 55, 89, 19, 36, 35, 40, 113, 131, 141, 173, 234, 254, 231, 300, 241;
12131219
}

0 commit comments

Comments
 (0)