From a37e37c96f0de3939a8c2d873df5f3103589fc48 Mon Sep 17 00:00:00 2001 From: Radhika Chippada Date: Wed, 11 Mar 2015 09:31:44 -0400 Subject: [PATCH] 3761: add a test with invalid data manager token and expect the item to be rejected. --- services/keepstore/pull_worker_test.go | 32 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/services/keepstore/pull_worker_test.go b/services/keepstore/pull_worker_test.go index dc6d462766..f0e9e65f1e 100644 --- a/services/keepstore/pull_worker_test.go +++ b/services/keepstore/pull_worker_test.go @@ -218,6 +218,25 @@ func (s *PullWorkerTestSuite) TestPullWorker_pull_list_with_two_items_latest_rep performTest(testData, c) } +// In this case, the item will not be placed on pullq +func (s *PullWorkerTestSuite) TestPullWorker_invalid_data_manager_token(c *C) { + defer teardown() + + data_manager_token = "DATA MANAGER TOKEN" + + testData := PullWorkerTestData{ + name: "TestPullWorker_pull_list_with_two_locators", + req: RequestTester{"/pull", "invalid_data_manager_token", "PUT", first_pull_list}, + response_code: http.StatusUnauthorized, + response_body: "Unauthorized\n", + read_content: "hello", + read_error: false, + put_error: false, + } + + performTest(testData, c) +} + func performTest(testData PullWorkerTestData, c *C) { RunTestPullWorker(c) @@ -269,14 +288,19 @@ func performTest(testData PullWorkerTestData, c *C) { c.Assert(testPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil) c.Assert(processedPullLists["TestPullWorker_pull_list_with_two_items_latest_replacing_old"], NotNil) } else { - c.Assert(len(testPullLists), Equals, 1) - c.Assert(len(processedPullLists), Equals, 1) - c.Assert(testPullLists[testData.name], NotNil) + if testData.response_code == http.StatusOK { + c.Assert(len(testPullLists), Equals, 1) + c.Assert(len(processedPullLists), Equals, 1) + c.Assert(testPullLists[testData.name], NotNil) + } else { + c.Assert(len(testPullLists), Equals, 1) + c.Assert(len(processedPullLists), Equals, 0) + } } if testData.read_error { c.Assert(readError, NotNil) - } else { + } else if testData.response_code == http.StatusOK { c.Assert(readError, IsNil) c.Assert(readContent, Equals, testData.read_content) if testData.put_error { -- 2.30.2