@@ -1385,6 +1385,7 @@ var _ = Describe("GCP Bootstrapper", func() {
13851385 Describe ("InstallCodesphere" , func () {
13861386 BeforeEach (func () {
13871387 csEnv .InstallVersion = "v1.2.3"
1388+ csEnv .InstallHash = "abc1234567890"
13881389 })
13891390 Describe ("Valid InstallCodesphere" , func () {
13901391 Context ("Direct GitHub access" , func () {
@@ -1396,23 +1397,37 @@ var _ = Describe("GCP Bootstrapper", func() {
13961397 })
13971398 It ("downloads and installs lite package" , func () {
13981399 // Expect download package
1399- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer-lite.tar.gz v1.2.3" ).Return (nil )
1400+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer-lite.tar.gz -H abc1234567890 v1.2.3" ).Return (nil )
14001401
14011402 // Expect install codesphere
14021403 nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" ,
1403- "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-installer-lite.tar.gz -s load-container-images" ).Return (nil )
1404+ "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-abc1234567890- installer-lite.tar.gz -s load-container-images" ).Return (nil )
14041405
14051406 err := bs .InstallCodesphere ()
14061407 Expect (err ).NotTo (HaveOccurred ())
14071408 })
14081409 })
14091410
1410- It ("downloads and installs codesphere" , func () {
1411- // Expect download package
1412- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz v1.2.3" ).Return (nil )
1411+ Context ("without explicit hash" , func () {
1412+ BeforeEach (func () {
1413+ // Simulate that ValidateInput has populated the hash
1414+ csEnv .InstallHash = "def9876543210"
1415+ })
1416+ It ("downloads and installs codesphere" , func () {
1417+ // Expect download package
1418+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz -H def9876543210 v1.2.3" ).Return (nil )
1419+
1420+ // Expect install codesphere
1421+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-def9876543210-installer.tar.gz" ).Return (nil )
1422+
1423+ err := bs .InstallCodesphere ()
1424+ Expect (err ).NotTo (HaveOccurred ())
1425+ })
1426+ })
14131427
1414- // Expect install codesphere
1415- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-installer.tar.gz" ).Return (nil )
1428+ It ("downloads and installs codesphere with hash" , func () {
1429+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz -H abc1234567890 v1.2.3" ).Return (nil )
1430+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-abc1234567890-installer.tar.gz" ).Return (nil )
14161431
14171432 err := bs .InstallCodesphere ()
14181433 Expect (err ).NotTo (HaveOccurred ())
@@ -1421,16 +1436,16 @@ var _ = Describe("GCP Bootstrapper", func() {
14211436
14221437 Describe ("Invalid cases" , func () {
14231438 It ("fails when download package fails" , func () {
1424- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz v1.2.3" ).Return (fmt .Errorf ("download error" ))
1439+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz -H abc1234567890 v1.2.3" ).Return (fmt .Errorf ("download error" ))
14251440
14261441 err := bs .InstallCodesphere ()
14271442 Expect (err ).To (HaveOccurred ())
14281443 Expect (err .Error ()).To (ContainSubstring ("failed to download Codesphere package from jumpbox" ))
14291444 })
14301445
14311446 It ("fails when install codesphere fails" , func () {
1432- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz v1.2.3" ).Return (nil ).Once ()
1433- nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-installer.tar.gz" ).Return (fmt .Errorf ("install error" )).Once ()
1447+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli download package -f installer.tar.gz -H abc1234567890 v1.2.3" ).Return (nil ).Once ()
1448+ nodeClient .EXPECT ().RunCommand (mock .MatchedBy (jumpbboxMatcher ), "root" , "oms-cli install codesphere -c /etc/codesphere/config.yaml -k /etc/codesphere/secrets/age_key.txt -p v1.2.3-abc1234567890- installer.tar.gz" ).Return (fmt .Errorf ("install error" )).Once ()
14341449
14351450 err := bs .InstallCodesphere ()
14361451 Expect (err ).To (HaveOccurred ())
0 commit comments