-
Notifications
You must be signed in to change notification settings - Fork 216
Certz4-modified timeout value in trust_bundle.go #5452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 155 commits
07ac30d
bc42b9b
aba3b0a
c300c3f
7d6c344
b7dfda7
8a8ad0e
6a29dfb
2e42b13
53191df
da23136
af659cc
261161a
b8fd96d
73911ba
2a2a1ec
08ff7e9
ec5b53b
38ddffa
3297006
d50ba6f
bd4d696
df1a5c1
878802e
0bc32cf
4d2b110
f12dac8
e3100b2
274d5a1
85564f9
cdade39
702811f
abb6b7b
82c56df
14c997e
10cc144
a4b277a
a59aae8
abf9325
827a639
0001e58
5fd4997
5868780
1f28b2d
760f41f
f526ddf
11cb32a
beffe47
c7e29de
ae649fd
6a6a9da
133beac
b758f08
5c34135
06d6d9a
8a7c48c
465efd8
f49c69d
089dea4
1579892
2928bcf
1f11db1
1be59d1
cee59fd
46dc697
ad78def
1705959
9e4db92
4379d57
616ad24
d594a6e
2c59615
c6fbc77
0d80790
9720a5b
d533439
f5d58d2
21c255f
497cc47
55ce46d
2259c95
ca1db6f
9fd9322
7d2e162
3ccf327
e2ee04f
a6a8bff
c30d329
29974cc
f008a46
09d865b
75616d0
1b6d393
9a655f3
02a7e3a
7cc12b7
2966920
7afe91a
644093e
1ac5397
6ef9a9c
19d63ae
c6bf410
193a532
daf44b4
bc07422
c3112bb
e6f0627
b537f78
7e0b49f
4a89776
7aa830a
56af4b1
c333769
93bf990
a1c56b3
a757041
1d2dfb0
6d85f30
25c7a3e
900ea09
afd08b3
6a24e94
5a3f23d
25c3c80
2049593
0deac10
f4aeae2
a5a2413
695f05f
b7d22f1
a02575f
b2cfa79
43c4d86
7a8d15c
6e66ad4
0dae9fc
9c88828
f8be609
fff7363
320d8a7
15a4618
58ad7d5
bbb1aeb
a532d06
691e371
eff732b
c249f0f
42752a6
6b70f81
4fa220d
1ebe3cb
52917d1
48b69f4
35e5bdf
4c71918
fe4368f
d224b5e
cb2c963
d37b71f
84f7f10
d561294
92dec75
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,7 +32,7 @@ import ( | |||||
|
|
||||||
| const ( | ||||||
| dirPath = "../../test_data/" | ||||||
| timeOutVar time.Duration = 2 * time.Minute | ||||||
| timeOutVar time.Duration = 180 * time.Minute | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The timeout
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value is intentional because the script invokes mk_cas.sh to create 20k certs. This generation of certs takes significant amount of time, close to 3 hours. |
||||||
| ) | ||||||
|
|
||||||
| // DUTCredentialer is an interface for getting credentials from a DUT binding. | ||||||
|
|
@@ -63,37 +63,37 @@ func TestTrustBundleCert(t *testing.T) { | |||||
| dut := ondatra.DUT(t, "dut") | ||||||
| serverAddr = dut.Name() //returns the device name. | ||||||
| if err := binding.DUTAs(dut.RawAPIs().BindingDUT(), &creds); err != nil { | ||||||
| t.Fatalf("%s:STATUS:Failed to get DUT credentials using binding.DUTAs: %v. The binding for %s must implement the DUTCredentialer interface.", logTime, err, dut.Name()) | ||||||
| t.Fatalf("%s:STATUS:Failed to get DUT credentials using binding.DUTAs: %v. The binding for %s must implement the DUTCredentialer interface.", time.Now().String(), err, dut.Name()) | ||||||
|
sudhirakondi marked this conversation as resolved.
Outdated
|
||||||
| } | ||||||
| username := creds.RPCUsername() | ||||||
| password := creds.RPCPassword() | ||||||
| t.Logf("%s:STATUS:Validation of all services that are using gRPC before certz rotation.", logTime) | ||||||
| t.Logf("%s:STATUS:Validation of all services that are using gRPC before certz rotation.", time.Now().String()) | ||||||
| gnmiClient, gnsiC := setup_service.PreInitCheck(context.Background(), t, dut) | ||||||
| //Generate testdata certificates. | ||||||
| t.Logf("%s:Creation of test data.", logTime) | ||||||
| t.Logf("%s:Creation of test data.", time.Now().String()) | ||||||
| if err := setup_service.TestdataMakeCleanup(t, dirPath, timeOutVar, "./mk_cas.sh"); err != nil { | ||||||
| t.Logf("%s:STATUS:Generation of testdata certificates failed!: %v", logTime, err) | ||||||
| t.Logf("%s:STATUS:Generation of testdata certificates failed!: %v", time.Now().String(), err) | ||||||
| } | ||||||
| //Create a certz client. | ||||||
| ctx := context.Background() | ||||||
| certzClient := gnsiC.Certz() | ||||||
| t.Logf("%s:STATUS:Precheck:checking baseline sslprofile list.", logTime) | ||||||
| t.Logf("%s:STATUS:Precheck:checking baseline sslprofile list.", time.Now().String()) | ||||||
| //Get sslprofile list. | ||||||
| if getResp := setup_service.GetSslProfilelist(ctx, t, certzClient, &certzpb.GetProfileListRequest{}); slices.Contains(getResp.SslProfileIds, testProfile) { | ||||||
| t.Fatalf("%s:STATUS:profileID %s already exists.", logTime, testProfile) | ||||||
| t.Fatalf("%s:STATUS:profileID %s already exists.", time.Now().String(), testProfile) | ||||||
| } | ||||||
| //Add new sslprofileID. | ||||||
| t.Logf("%s:Adding new empty sslprofile ID %s.", logTime, testProfile) | ||||||
| t.Logf("%s:Adding new empty sslprofile ID %s.", time.Now().String(), testProfile) | ||||||
| if addProfileResponse, err := certzClient.AddProfile(ctx, &certzpb.AddProfileRequest{SslProfileId: testProfile}); err != nil { | ||||||
| t.Fatalf("%s:STATUS:Add profile request failed with %v! ", logTime, err) | ||||||
| t.Fatalf("%s:STATUS:Add profile request failed with %v! ", time.Now().String(), err) | ||||||
| } else { | ||||||
| t.Logf("%s:STATUS:Received the AddProfileResponse %v.", logTime, addProfileResponse) | ||||||
| t.Logf("%s:STATUS:Received the AddProfileResponse %v.", time.Now().String(), addProfileResponse) | ||||||
| } | ||||||
| //Get sslprofile list after new sslprofile addition. | ||||||
| if getResp := setup_service.GetSslProfilelist(ctx, t, certzClient, &certzpb.GetProfileListRequest{}); !slices.Contains(getResp.SslProfileIds, testProfile) { | ||||||
| t.Fatalf("%s:STATUS:newly added profileID is not seen.", logTime) | ||||||
| t.Fatalf("%s:STATUS:newly added profileID is not seen.", time.Now().String()) | ||||||
| } else { | ||||||
| t.Logf("%s:STATUS:new profileID %s is seen in sslprofile list", logTime, testProfile) | ||||||
| t.Logf("%s:STATUS:new profileID %s is seen in sslprofile list", time.Now().String(), testProfile) | ||||||
| } | ||||||
| cases := []struct { | ||||||
| desc string | ||||||
|
|
@@ -200,7 +200,7 @@ func TestTrustBundleCert(t *testing.T) { | |||||
| } | ||||||
| for _, tc := range cases { | ||||||
| t.Run(tc.desc, func(t *testing.T) { | ||||||
| t.Logf("%s:STATUS:Starting test case: %s", logTime, tc.desc) | ||||||
| t.Logf("%s:STATUS:Starting test case: %s", time.Now().String(), tc.desc) | ||||||
| //Read the serverSAN (Subject Alternative Name) from the certificate used for TLS verification. | ||||||
| serverSAN := setup_service.ReadDecodeServerCertificate(t, tc.serverCertFile) | ||||||
| //Build serverCertEntity for the server certificate rotation. | ||||||
|
|
@@ -212,7 +212,7 @@ func TestTrustBundleCert(t *testing.T) { | |||||
| //Create a new Cert Pool and add the certs from the trust bundle. | ||||||
| pkcs7certs, pkcs7data, err := setup_service.Loadpkcs7TrustBundle(tc.trustBundleFile) | ||||||
| if err != nil { | ||||||
| t.Fatalf("%s:STATUS:failed to load trust bundle: %v", logTime, err) | ||||||
| t.Fatalf("%s:STATUS:failed to load trust bundle: %v", time.Now().String(), err) | ||||||
| } | ||||||
| newCaCert := x509.NewCertPool() | ||||||
| for _, c := range pkcs7certs { | ||||||
|
|
@@ -223,18 +223,18 @@ func TestTrustBundleCert(t *testing.T) { | |||||
| //Load Client certificate. | ||||||
| newClientCert, err := tls.LoadX509KeyPair(tc.clientCertFile, tc.clientKeyFile) | ||||||
| if err != nil { | ||||||
| t.Fatalf("%s:STATUS:Failed to load client cert:%v", logTime, err) | ||||||
| t.Fatalf("%s:STATUS:Failed to load client cert:%v", time.Now().String(), err) | ||||||
| } | ||||||
| if tc.newTLScreds { | ||||||
| t.Logf("%s:STATUS:%s:Creating new TLS credentials for client connection.", logTime, tc.desc) | ||||||
| t.Logf("%s:STATUS:%s:Creating new TLS credentials for client connection.", time.Now().String(), tc.desc) | ||||||
| //Load the prior client keypair for new client TLS credentials. | ||||||
| prevClientCert, err := tls.LoadX509KeyPair(prevClientCertFile, prevClientKeyFile) | ||||||
| if err != nil { | ||||||
| t.Fatalf("%s:STATUS:%s:Failed to load previous client cert: %v", logTime, tc.desc, err) | ||||||
| t.Fatalf("%s:STATUS:%s:Failed to load previous client cert: %v", time.Now().String(), tc.desc, err) | ||||||
| } | ||||||
| oldPkcs7certs, oldPkcs7data, err := setup_service.Loadpkcs7TrustBundle(prevTrustBundleFile) | ||||||
| if err != nil { | ||||||
| t.Fatalf("%s:STATUS:%sFailed to load previous trust bundle,data %v with %v", logTime, tc.desc, oldPkcs7data, err) | ||||||
| t.Fatalf("%s:STATUS:%sFailed to load previous trust bundle,data %v with %v", time.Now().String(), tc.desc, oldPkcs7data, err) | ||||||
| } | ||||||
| //Create a old set of Cert Pool and append the certs from previous trust bundle. | ||||||
| prevCaCert := x509.NewCertPool() | ||||||
|
|
@@ -243,39 +243,39 @@ func TestTrustBundleCert(t *testing.T) { | |||||
| } | ||||||
| //Before rotation,validation of all services with existing certificates. | ||||||
| if result := setup_service.ServicesValidationCheck(t, prevCaCert, expectedResult, serverSAN, serverAddr, username, password, prevClientCert, tc.mismatch); !result { | ||||||
| t.Fatalf("%s:STATUS:%s:service validation failed before rotate- got %v, want %v.", logTime, tc.desc, result, expectedResult) | ||||||
| t.Fatalf("%s:STATUS:%s:service validation failed before rotate- got %v, want %v.", time.Now().String(), tc.desc, result, expectedResult) | ||||||
| } | ||||||
| //Retrieve the connection with previous TLS credentials for certz rotation. | ||||||
| conn := setup_service.CreateNewDialOption(t, prevClientCert, prevCaCert, serverSAN, username, password, serverAddr) | ||||||
| defer conn.Close() | ||||||
| certzClient = certzpb.NewCertzClient(conn) | ||||||
| gnmiClient = gnmi.NewGNMIClient(conn) | ||||||
| } else { | ||||||
| t.Logf("%s:STATUS:%s:Using existing TLS credentials for client connection in first iteration.", logTime, tc.desc) | ||||||
| t.Logf("%s:STATUS:%s:Using existing TLS credentials for client connection in first iteration.", time.Now().String(), tc.desc) | ||||||
| } | ||||||
| //Initiate trustbundle rotation. | ||||||
| t.Logf("STATUS:%s Initiating Certz rotation with server cert: %s and trust bundle: %s.", tc.desc, tc.serverCertFile, tc.trustBundleFile) | ||||||
| if success := setup_service.CertzRotate(ctx, t, newCaCert, certzClient, gnmiClient, newClientCert, dut, username, password, serverSAN, serverAddr, testProfile, tc.newTLScreds, tc.mismatch, tc.scale, &serverCertEntity, &trustBundleEntity); !success { | ||||||
| t.Fatalf("%s:STATUS: %s:CertzRotation failed.", logTime, tc.desc) | ||||||
| t.Fatalf("%s:STATUS: %s:CertzRotation failed.", time.Now().String(), tc.desc) | ||||||
| } | ||||||
| t.Logf("%s:STATUS:%s: TrustBundle rotation completed!", logTime, tc.desc) | ||||||
| t.Logf("%s:STATUS:%s: TrustBundle rotation completed!", time.Now().String(), tc.desc) | ||||||
| //Post rotate validation of all services. | ||||||
| t.Run("Verification of new connection after successful trustBundle rotation", func(t *testing.T) { | ||||||
| if result := setup_service.ServicesValidationCheck(t, newCaCert, expectedResult, serverSAN, serverAddr, username, password, newClientCert, tc.mismatch); !result { | ||||||
| t.Fatalf("STATUS:%s:service validation failed after rotate- got %v, want %v.", tc.desc, result, expectedResult) | ||||||
| } | ||||||
| t.Logf("%s:STATUS:%s:service validation done!", logTime, tc.desc) | ||||||
| t.Logf("%s:STATUS:%s:service validation done!", time.Now().String(), tc.desc) | ||||||
| }) | ||||||
| //Archiving previous client cert/key and trustbundle. | ||||||
| prevClientCertFile = tc.clientCertFile | ||||||
| prevClientKeyFile = tc.clientKeyFile | ||||||
| prevTrustBundleFile = tc.trustBundleFile | ||||||
| }) | ||||||
| } | ||||||
| t.Logf("%s:STATUS:Cleanup of test data.", logTime) | ||||||
| t.Logf("%s:STATUS:Cleanup of test data.", time.Now().String()) | ||||||
| //Cleanup of test data. | ||||||
| if err := setup_service.TestdataMakeCleanup(t, dirPath, timeOutVar, "./cleanup.sh"); err != nil { | ||||||
| t.Logf("%s:STATUS:Cleanup of testdata certificates failed!: %v", logTime, err) | ||||||
| t.Logf("%s:STATUS:Cleanup of testdata certificates failed!: %v", time.Now().String(), err) | ||||||
| } | ||||||
| t.Logf("%s:STATUS:Test completed!", logTime) | ||||||
| t.Logf("%s:STATUS:Test completed!", time.Now().String()) | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.