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 m : namespace kasko {
26 :
27 m : TEST(HttpAgentImplTest, SimpleUpload) {
28 m : testing::TestServer server;
29 m : ASSERT_TRUE(server.Start());
30 :
31 m : base::string16 url =
32 m : L"http://localhost:" + base::UintToString16(server.port()) + L"/path";
33 m : HttpAgentImpl agent_impl(L"test", L"0.0");
34 m : base::string16 response_body;
35 m : uint16_t response_code = 0;
36 m : ASSERT_TRUE(SendHttpUpload(
37 m : &agent_impl, url, std::map<base::string16, base::string16>(),
38 m : "file_contents", L"file_name", &response_body, &response_code));
39 :
40 m : EXPECT_EQ(L"file_name=file_contents\r\n", response_body);
41 m : EXPECT_EQ(200, response_code);
42 m : }
43 :
44 m : } // namespace kasko
|