Allow HTTP urls when device policy doesn't specify.
BUG=chromium:277835
TEST=Unittest
Change-Id: I638248dcbdbdaf48e38b79638b2348aa6c1400fb
Reviewed-on: https://gerrit.chromium.org/gerrit/66732
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 8fffab9..d4eaa5b 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -1087,12 +1087,24 @@
policy::MockDevicePolicy disable_http_policy;
EXPECT_CALL(mock_system_state, device_policy())
.WillRepeatedly(Return(&disable_http_policy));
+ EXPECT_TRUE(payload_state.Initialize(&mock_system_state));
+
+ // Test with no device policy. Should default to allowing http.
+ EXPECT_CALL(disable_http_policy, GetHttpDownloadsEnabled(_))
+ .WillRepeatedly(Return(false));
+
+ // Set the first response.
+ SetupPayloadStateWith2Urls("Hash8433", true, &payload_state, &response);
+
+ // Check that we use the HTTP URL since there is no value set for allowing
+ // http.
+ EXPECT_EQ("http://test", payload_state.GetCurrentUrl());
+
+ // Test with device policy not allowing http updates.
EXPECT_CALL(disable_http_policy, GetHttpDownloadsEnabled(_))
.WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(true)));
- EXPECT_TRUE(payload_state.Initialize(&mock_system_state));
-
- // Set the first response.
+ // Reset state and set again.
SetupPayloadStateWith2Urls("Hash8433", false, &payload_state, &response);
// Check that we skip the HTTP URL and use only the HTTPS url.