Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated fix for refs/heads/local_creds #9

Open
wants to merge 1 commit into
base: local_creds
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions build_autogenerated.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4069,9 +4069,9 @@ grpc_cc_library(
"//:promise",
"//:ref_counted_ptr",
"//:sockaddr_utils",
"//src/core:experiments",
"//:tsi_base",
"//:uri_parser",
"//src/core:experiments",
],
)

Expand Down
17 changes: 1 addition & 16 deletions src/core/lib/experiments/experiments.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions src/core/lib/experiments/experiments.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ void local_check_peer(tsi_peer peer, grpc_endpoint* ep,
if (grpc_core::IsLocalConnectorSecureEnabled()) {
switch (type) {
case UDS:
security_level = tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY);
security_level =
tsi_security_level_to_string(TSI_PRIVACY_AND_INTEGRITY);
break;
default:
security_level = tsi_security_level_to_string(TSI_SECURITY_NONE);
Expand Down
100 changes: 43 additions & 57 deletions test/core/security/local_security_connector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

#include <gtest/gtest.h>

#include "googletest/include/gtest/gtest.h"

#include <grpc/impl/grpc_types.h>

#include "src/core/client_channel/client_channel_filter.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/tsi/transport_security.h"
#include "test/core/test_util/test_config.h"
#include "src/core/client_channel/client_channel_filter.h"
#include "include/grpc/impl/grpc_types.h"
#include "googletest/include/gtest/gtest.h"

namespace grpc_core {
namespace testing {
Expand All @@ -33,40 +35,28 @@ absl::string_view me_get_local_address_unix(grpc_endpoint* /*ep*/) {
return "unix:";
}

const grpc_endpoint_vtable vtable_unix = {nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
me_get_local_address_unix,
nullptr,
nullptr};
const grpc_endpoint_vtable vtable_unix = {
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, me_get_local_address_unix,
nullptr, nullptr};

absl::string_view me_get_local_address_local(grpc_endpoint* /*ep*/) {
return "ipv4:127.0.0.1:12667";
}

const grpc_endpoint_vtable vtable_local = {nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
me_get_local_address_local,
nullptr,
nullptr};
const grpc_endpoint_vtable vtable_local = {
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, me_get_local_address_local,
nullptr, nullptr};

void check_tsi_security_level_server(grpc_local_connect_type connect_type,
tsi_security_level level,
grpc_endpoint ep) {
grpc_server_credentials
* server_creds = grpc_local_server_credentials_create(connect_type);
tsi_security_level level,
grpc_endpoint ep) {
grpc_server_credentials* server_creds =
grpc_local_server_credentials_create(connect_type);
ChannelArgs args;
RefCountedPtr<grpc_server_security_connector> connector = server_creds->
create_security_connector(args);
RefCountedPtr<grpc_server_security_connector> connector =
server_creds->create_security_connector(args);
ASSERT_NE(connector, nullptr);
tsi_peer peer;
CHECK(tsi_construct_peer(0, &peer) == TSI_OK);
Expand All @@ -84,21 +74,21 @@ void check_tsi_security_level_server(grpc_local_connect_type connect_type,
grpc_server_credentials_release(server_creds);
}

static void check_tsi_security_level_channel(grpc_local_connect_type connect_type,
tsi_security_level level,
grpc_endpoint ep) {
grpc_channel_credentials
* channel_creds = grpc_local_credentials_create(connect_type);
void check_tsi_security_level_channel(grpc_local_connect_type connect_type,
tsi_security_level level,
grpc_endpoint ep) {
grpc_channel_credentials* channel_creds =
grpc_local_credentials_create(connect_type);
ChannelArgs args;
args = args.Set((char*) GRPC_ARG_SERVER_URI, (char*) "unix:");
args = args.Set((char*)GRPC_ARG_SERVER_URI, (char*)"unix:");
const char* target_name;
if (connect_type == UDS) {
target_name = "unix:";
} else {
target_name = "localhost";
}
RefCountedPtr<grpc_channel_security_connector> connector = channel_creds->
create_security_connector(nullptr, "unix:", &args);
RefCountedPtr<grpc_channel_security_connector> connector =
channel_creds->create_security_connector(nullptr, "unix:", &args);

ASSERT_NE(connector, nullptr);
tsi_peer peer;
Expand All @@ -124,35 +114,31 @@ static void check_tsi_security_level_channel(grpc_local_connect_type connect_typ
//

TEST(LocalSecurityConnectorTest, CheckUDSType) {
grpc_endpoint ep = {
.vtable = &vtable_unix,
};
check_tsi_security_level_server(UDS, TSI_PRIVACY_AND_INTEGRITY, ep
);
grpc_endpoint ep = {
.vtable = &vtable_unix,
};
check_tsi_security_level_server(UDS, TSI_PRIVACY_AND_INTEGRITY, ep);
}

TEST(LocalSecurityConnectorTest, CheckLocalType) {
grpc_endpoint ep = {
.vtable = &vtable_local,
};
check_tsi_security_level_server(LOCAL_TCP, TSI_SECURITY_NONE, ep
);
grpc_endpoint ep = {
.vtable = &vtable_local,
};
check_tsi_security_level_server(LOCAL_TCP, TSI_SECURITY_NONE, ep);
}

TEST(LocalSecurityConnectorTest, CheckUDSTypeChannel) {
grpc_endpoint ep = {
.vtable = &vtable_unix,
};
check_tsi_security_level_channel(UDS, TSI_PRIVACY_AND_INTEGRITY, ep
);
grpc_endpoint ep = {
.vtable = &vtable_unix,
};
check_tsi_security_level_channel(UDS, TSI_PRIVACY_AND_INTEGRITY, ep);
}

TEST(LocalSecurityConnectorTest, CheckLocalTypeChannel) {
grpc_endpoint ep = {
.vtable = &vtable_local,
};
check_tsi_security_level_channel(LOCAL_TCP, TSI_SECURITY_NONE, ep
);
grpc_endpoint ep = {
.vtable = &vtable_local,
};
check_tsi_security_level_channel(LOCAL_TCP, TSI_SECURITY_NONE, ep);
}

} // namespace
Expand Down
Loading