1 : // Copyright 2014 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 :
15 : #include "syzygy/kasko/http_agent_impl.h"
16 :
17 : #include <map>
18 : #include <string>
19 :
20 : #include "base/strings/string_number_conversions.h"
21 : #include "gtest/gtest.h"
22 : #include "syzygy/kasko/upload.h"
23 : #include "syzygy/kasko/testing/test_server.h"
24 :
25 : namespace kasko {
26 :
27 E : TEST(HttpAgentImplTest, SimpleUpload) {
28 E : testing::TestServer server;
29 E : ASSERT_TRUE(server.Start());
30 :
31 : base::string16 url =
32 E : L"http://localhost:" + base::UintToString16(server.port()) + L"/path";
33 E : HttpAgentImpl agent_impl(L"test", L"0.0");
34 E : base::string16 response_body;
35 E : uint16_t response_code = 0;
36 : ASSERT_TRUE(SendHttpUpload(
37 : &agent_impl, url, std::map<base::string16, base::string16>(),
38 E : "file_contents", L"file_name", &response_body, &response_code));
39 :
40 E : EXPECT_EQ(L"file_name=file_contents\r\n", response_body);
41 E : EXPECT_EQ(200, response_code);
42 E : }
43 :
44 : } // namespace kasko
|