Commit d1445845 authored by scf's avatar scf Committed by Commit bot

remove CHANNEL_AUTH_TYPE_SSL from ChannelAuthType

Its not being used, except from unit tests.

BUG=644430

Review-Url: https://codereview.chromium.org/2559283003
Cr-Commit-Position: refs/heads/master@{#438040}
parent 2ae3356d
......@@ -8,7 +8,7 @@ assertOpenChannel = function(channel) {
chrome.test.assertTrue(channel.channelId > 0);
chrome.test.assertTrue(channel.connectInfo.ipAddress == '192.168.1.1');
chrome.test.assertTrue(channel.connectInfo.port == 8009);
chrome.test.assertTrue(channel.connectInfo.auth == 'ssl');
chrome.test.assertTrue(channel.connectInfo.auth == 'ssl_verified');
chrome.test.assertTrue(channel.readyState == 'open');
chrome.test.assertTrue(channel.errorState == undefined);
};
......@@ -23,7 +23,7 @@ assertClosedChannelWithError = function(channel, error) {
chrome.test.assertTrue(channel.channelId > 0);
chrome.test.assertTrue(channel.connectInfo.ipAddress == '192.168.1.1');
chrome.test.assertTrue(channel.connectInfo.port == 8009);
chrome.test.assertTrue(channel.connectInfo.auth == 'ssl');
chrome.test.assertTrue(channel.connectInfo.auth == 'ssl_verified');
chrome.test.assertTrue(channel.readyState == 'closed');
chrome.test.assertTrue(channel.errorState == error);
};
......@@ -29,5 +29,8 @@ var onOpen = function(channel) {
chrome.cast.channel.send(channel, message, onSend);
};
chrome.cast.channel.open({ipAddress: '192.168.1.1', port: 8009, auth: 'ssl'},
onOpen);
chrome.cast.channel.open({
ipAddress: '192.168.1.1',
port: 8009,
auth: 'ssl_verified'
}, onOpen);
......@@ -33,5 +33,7 @@ var maybeClose = function(channel) {
};
chrome.cast.channel.onError.addListener(onError);
chrome.cast.channel.open({ipAddress: '192.168.1.1', port: 8009, auth: 'ssl'},
onOpen);
chrome.cast.channel.open({
ipAddress: '192.168.1.1',
port: 8009,
auth: 'ssl_verified'}, onOpen);
......@@ -30,5 +30,7 @@ var onOpen = function(channel) {
chrome.test.notifyPass();
};
chrome.cast.channel.open({ipAddress: '192.168.1.1', port: 8009, auth: 'ssl'},
onOpen);
chrome.cast.channel.open({
ipAddress: '192.168.1.1',
port: 8009,
auth: 'ssl_verified'}, onOpen);
......@@ -23,6 +23,7 @@ var onOpen = function(channel) {
assertOpenChannel(channel);
chrome.cast.channel.send(channel, message, onSend);
};
chrome.cast.channel.open({ipAddress: '192.168.1.1', port: 8009, auth: 'ssl'},
onOpen);
chrome.cast.channel.open({
ipAddress: '192.168.1.1',
port: 8009,
auth: 'ssl_verified'}, onOpen);
......@@ -6,7 +6,7 @@
chrome.cast.channel.open({
ipAddress: '192.168.1.1',
port: 8009,
auth: 'ssl',
auth: 'ssl_verified',
livenessTimeout: 5000,
pingInterval: 1000
}, function(channel) {
......
......@@ -225,7 +225,7 @@ void CastChannelAsyncApiFunction::SetResultFromError(int channel_id,
channel_info.error_state = error;
channel_info.connect_info.ip_address = "";
channel_info.connect_info.port = 0;
channel_info.connect_info.auth = cast_channel::CHANNEL_AUTH_TYPE_SSL;
channel_info.connect_info.auth = cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED;
SetResultFromChannelInfo(channel_info);
SetError("Channel error = " + base::IntToString(error));
}
......
......@@ -22,7 +22,7 @@ TEST(CastChannelOpenFunctionTest, TestParseConnectInfo) {
ConnectInfo connect_info;
connect_info.ip_address = "192.0.0.1";
connect_info.port = 8009;
connect_info.auth = CHANNEL_AUTH_TYPE_SSL;
connect_info.auth = CHANNEL_AUTH_TYPE_SSL_VERIFIED;
ip_endpoint.reset(ccof::ParseConnectInfo(connect_info));
EXPECT_TRUE(ip_endpoint);
......
......@@ -108,7 +108,7 @@ class CastChannelAPITest : public ExtensionApiTest {
ON_CALL(*mock_cast_socket_, ip_endpoint())
.WillByDefault(ReturnRef(ip_endpoint_));
ON_CALL(*mock_cast_socket_, channel_auth())
.WillByDefault(Return(cast_channel::CHANNEL_AUTH_TYPE_SSL));
.WillByDefault(Return(cast_channel::CHANNEL_AUTH_TYPE_SSL_VERIFIED));
ON_CALL(*mock_cast_socket_, keep_alive()).WillByDefault(Return(false));
}
......@@ -388,16 +388,18 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestOpenInvalidConnectInfo) {
cast_channel_open_function = CreateOpenFunction(empty_extension);
std::string error = utils::RunFunctionAndReturnError(
cast_channel_open_function.get(),
"[{\"ipAddress\": \"invalid_ip\", \"port\": 8009, \"auth\": \"ssl\"}]",
"[{\"ipAddress\": \"invalid_ip\", \"port\": 8009, \"auth\": "
"\"ssl_verified\"}]",
browser());
EXPECT_EQ(error, "Invalid connect_info (invalid IP address)");
// Invalid port
cast_channel_open_function = CreateOpenFunction(empty_extension);
error = utils::RunFunctionAndReturnError(
cast_channel_open_function.get(),
"[{\"ipAddress\": \"127.0.0.1\", \"port\": -200, \"auth\": \"ssl\"}]",
browser());
error = utils::RunFunctionAndReturnError(cast_channel_open_function.get(),
"[{\"ipAddress\": \"127.0.0.1\", "
"\"port\": -200, \"auth\": "
"\"ssl_verified\"}]",
browser());
EXPECT_EQ(error, "Invalid connect_info (invalid port)");
}
......@@ -415,7 +417,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSendInvalidMessageInfo) {
"\"audioOnly\": false, "
"\"connectInfo\": "
"{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
"\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
"\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, "
"{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
"\"destinationId\": \"dest\", \"data\": 1235}]",
browser()));
......@@ -430,7 +432,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSendInvalidMessageInfo) {
"\"audioOnly\": false, "
"\"connectInfo\": "
"{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
"\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
"\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, "
"{\"namespace_\": \"\", \"sourceId\": \"src\", "
"\"destinationId\": \"dest\", \"data\": \"data\"}]",
browser());
......@@ -445,7 +447,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSendInvalidMessageInfo) {
"\"audioOnly\": false, "
"\"connectInfo\": "
"{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
"\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
"\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, "
"{\"namespace_\": \"foo\", \"sourceId\": \"\", "
"\"destinationId\": \"dest\", \"data\": \"data\"}]",
browser());
......@@ -460,7 +462,7 @@ IN_PROC_BROWSER_TEST_F(CastChannelAPITest, TestSendInvalidMessageInfo) {
"\"audioOnly\": false, "
"\"connectInfo\": "
"{\"ipAddress\": \"127.0.0.1\", \"port\": 8009, "
"\"auth\": \"ssl\"}, \"readyState\": \"open\"}, "
"\"auth\": \"ssl_verified\"}, \"readyState\": \"open\"}, "
"{\"namespace_\": \"foo\", \"sourceId\": \"src\", "
"\"destinationId\": \"\", \"data\": \"data\"}]",
browser());
......
......@@ -132,8 +132,6 @@ CastSocketImpl::CastSocketImpl(const std::string& owner_extension_id,
ready_state_(READY_STATE_NONE),
auth_delegate_(nullptr) {
DCHECK(net_log_);
DCHECK(channel_auth_ == CHANNEL_AUTH_TYPE_SSL ||
channel_auth_ == CHANNEL_AUTH_TYPE_SSL_VERIFIED);
net_log_source_.type = net::NetLogSourceType::SOCKET;
net_log_source_.id = net_log_->NextID();
}
......@@ -436,13 +434,7 @@ int CastSocketImpl::DoSslConnectComplete(int result) {
}
auth_delegate_ = new AuthTransportDelegate(this);
transport_->SetReadDelegate(base::WrapUnique(auth_delegate_));
if (channel_auth_ == CHANNEL_AUTH_TYPE_SSL_VERIFIED) {
// Additionally verify the connection with a handshake.
SetConnectState(proto::CONN_STATE_AUTH_CHALLENGE_SEND);
} else {
SetConnectState(proto::CONN_STATE_FINISHED);
transport_->Start();
}
SetConnectState(proto::CONN_STATE_AUTH_CHALLENGE_SEND);
} else if (result == net::ERR_CONNECTION_TIMED_OUT) {
SetConnectState(proto::CONN_STATE_FINISHED);
SetErrorState(CHANNEL_ERROR_CONNECT_TIMEOUT);
......
......@@ -28,6 +28,7 @@
#include "extensions/browser/api/cast_channel/cast_transport.h"
#include "extensions/browser/api/cast_channel/logger.h"
#include "extensions/common/api/cast_channel/cast_channel.pb.h"
#include "extensions/common/api/cast_channel/logging.pb.h"
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
#include "net/log/test_net_log.h"
......@@ -173,14 +174,6 @@ class CompleteHandler {
class TestCastSocket : public CastSocketImpl {
public:
static std::unique_ptr<TestCastSocket> Create(
Logger* logger,
uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) {
return std::unique_ptr<TestCastSocket>(
new TestCastSocket(CreateIPEndPointForTest(), CHANNEL_AUTH_TYPE_SSL,
kDistantTimeoutMillis, logger, device_capabilities));
}
static std::unique_ptr<TestCastSocket> CreateSecure(
Logger* logger,
uint64_t device_capabilities = cast_channel::CastDeviceCapability::NONE) {
......@@ -372,8 +365,6 @@ class CastSocketTest : public testing::Test {
}
}
void CreateCastSocket() { socket_ = TestCastSocket::Create(logger_); }
void CreateCastSocketSecure() {
socket_ = TestCastSocket::CreateSecure(logger_);
}
......@@ -412,68 +403,6 @@ class CastSocketTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(CastSocketTest);
};
// Tests connecting and closing the socket.
TEST_F(CastSocketTest, TestConnectAndClose) {
CreateCastSocket();
socket_->SetupMockTransport();
socket_->SetupTcpConnect(net::SYNCHRONOUS, net::OK);
socket_->SetupSslConnect(net::SYNCHRONOUS, net::OK);
EXPECT_CALL(handler_, OnConnectComplete(CHANNEL_ERROR_NONE));
socket_->Connect(std::move(delegate_),
base::Bind(&CompleteHandler::OnConnectComplete,
base::Unretained(&handler_)));
RunPendingTasks();
EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
EXPECT_CALL(handler_, OnCloseComplete(net::OK));
socket_->Close(base::Bind(&CompleteHandler::OnCloseComplete,
base::Unretained(&handler_)));
EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
}
// Tests that the following connection flow works:
// - TCP connection succeeds (async)
// - SSL connection succeeds (async)
TEST_F(CastSocketTest, TestConnect) {
CreateCastSocket();
socket_->SetupTcpConnect(net::ASYNC, net::OK);
socket_->SetupSslConnect(net::ASYNC, net::OK);
socket_->AddReadResult(net::ASYNC, net::ERR_IO_PENDING);
EXPECT_CALL(handler_, OnConnectComplete(CHANNEL_ERROR_NONE));
socket_->Connect(std::move(delegate_),
base::Bind(&CompleteHandler::OnConnectComplete,
base::Unretained(&handler_)));
RunPendingTasks();
EXPECT_EQ(cast_channel::READY_STATE_OPEN, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
}
// Tests that the following connection flow works:
// - TCP connection fails (async)
TEST_F(CastSocketTest, TestConnectFails) {
CreateCastSocket();
socket_->SetupTcpConnect(net::ASYNC, net::ERR_FAILED);
EXPECT_CALL(handler_, OnConnectComplete(CHANNEL_ERROR_CONNECT_ERROR));
socket_->Connect(std::move(delegate_),
base::Bind(&CompleteHandler::OnConnectComplete,
base::Unretained(&handler_)));
RunPendingTasks();
EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_CONNECT_ERROR, socket_->error_state());
EXPECT_EQ(proto::TCP_SOCKET_CONNECT_COMPLETE,
logger_->GetLastErrors(socket_->id()).event_type);
EXPECT_EQ(net::ERR_FAILED,
logger_->GetLastErrors(socket_->id()).net_return_value);
}
// Tests that the following connection flow works:
// - TCP connection succeeds (async)
// - SSL connection succeeds (async)
......@@ -692,44 +621,6 @@ TEST_F(CastSocketTest, TestConnectSslConnectTimeoutAsync) {
socket_->error_state());
}
// Test connection error - cert extraction error (async)
TEST_F(CastSocketTest, TestConnectCertExtractionErrorAsync) {
CreateCastSocket();
socket_->SetupTcpConnect(net::ASYNC, net::OK);
socket_->SetupSslConnect(net::ASYNC, net::OK);
// Set cert extraction to fail
socket_->SetExtractCertResult(false);
EXPECT_CALL(handler_, OnConnectComplete(CHANNEL_ERROR_AUTHENTICATION_ERROR));
socket_->Connect(std::move(delegate_),
base::Bind(&CompleteHandler::OnConnectComplete,
base::Unretained(&handler_)));
RunPendingTasks();
EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_AUTHENTICATION_ERROR,
socket_->error_state());
}
// Test connection error - cert extraction error (sync)
TEST_F(CastSocketTest, TestConnectCertExtractionErrorSync) {
CreateCastSocket();
socket_->SetupTcpConnect(net::SYNCHRONOUS, net::OK);
socket_->SetupSslConnect(net::SYNCHRONOUS, net::OK);
// Set cert extraction to fail
socket_->SetExtractCertResult(false);
EXPECT_CALL(handler_, OnConnectComplete(CHANNEL_ERROR_AUTHENTICATION_ERROR));
socket_->Connect(std::move(delegate_),
base::Bind(&CompleteHandler::OnConnectComplete,
base::Unretained(&handler_)));
RunPendingTasks();
EXPECT_EQ(cast_channel::READY_STATE_CLOSED, socket_->ready_state());
EXPECT_EQ(cast_channel::CHANNEL_ERROR_AUTHENTICATION_ERROR,
socket_->error_state());
}
// Test connection error - challenge send fails
TEST_F(CastSocketTest, TestConnectChallengeSendError) {
CreateCastSocketSecure();
......@@ -890,24 +781,6 @@ TEST_F(CastSocketTest, TestConnectEndToEndWithRealTransportSync) {
EXPECT_EQ(cast_channel::CHANNEL_ERROR_NONE, socket_->error_state());
}
// Tests channel policy verification for device with no capabilities.
TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesNone) {
socket_ =
TestCastSocket::Create(logger_, cast_channel::CastDeviceCapability::NONE);
EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone());
EXPECT_TRUE(socket_->TestVerifyChannelPolicyAudioOnly());
}
// Tests channel policy verification for device with video out capability.
TEST_F(CastSocketTest, TestChannelPolicyVerificationCapabilitiesVideoOut) {
socket_ = TestCastSocket::Create(
logger_, cast_channel::CastDeviceCapability::VIDEO_OUT);
EXPECT_FALSE(socket_->audio_only());
EXPECT_TRUE(socket_->TestVerifyChannelPolicyNone());
EXPECT_FALSE(socket_->audio_only());
EXPECT_FALSE(socket_->TestVerifyChannelPolicyAudioOnly());
EXPECT_TRUE(socket_->audio_only());
}
} // namespace cast_channel
} // namespace api
} // namespace extensions
......@@ -157,10 +157,7 @@ void Logger::LogNewSocketEvent(const CastSocket& cast_socket) {
const net::IPAddress& ip = cast_socket.ip_endpoint().address();
DCHECK(ip.IsValid());
aggregated_socket_event.set_endpoint_id(ip.bytes().back());
aggregated_socket_event.set_channel_auth_type(cast_socket.channel_auth() ==
CHANNEL_AUTH_TYPE_SSL
? proto::SSL
: proto::SSL_VERIFIED);
aggregated_socket_event.set_channel_auth_type(proto::SSL_VERIFIED);
}
void Logger::LogSocketEvent(int channel_id, EventType event_type) {
......
......@@ -51,8 +51,6 @@ namespace cast.channel {
// Authentication methods that may be required to connect to a Cast receiver.
enum ChannelAuthType {
// SSL over TCP.
ssl,
// SSL over TCP with challenge and receiver signature verification.
ssl_verified
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment