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 #5

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.

Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ class grpc_local_server_security_connector final
};
} // namespace

// just pass local and uds in the format of Chttp2FullstackLocalIpv4, Chttp2FullstackLocalIpv6, Chttp2FullstackLocalUds, check for results
// just pass local and uds in the format of Chttp2FullstackLocalIpv4,
// Chttp2FullstackLocalIpv6, Chttp2FullstackLocalUds, check for results

grpc_core::RefCountedPtr<grpc_channel_security_connector>
grpc_local_channel_security_connector_create(
Expand Down
62 changes: 30 additions & 32 deletions test/core/security/local_security_connector_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
//
//

#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"

#include <stdlib.h>
#include <string.h>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "absl/log/check.h"
#include "googletest/include/gtest/gtest.h"

#include <grpc/credentials.h>
#include <grpc/support/alloc.h>
Expand All @@ -39,10 +38,10 @@
#include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h"
#include "src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h"
#include "src/core/lib/security/credentials/tls/tls_credentials.h"
#include "src/core/lib/security/security_connector/tls/tls_security_connector.h"
#include "src/core/tsi/transport_security.h"
#include "test/core/test_util/test_config.h"
#include "test/core/test_util/tls_utils.h"
#include "googletest/include/gtest/gtest.h"

namespace grpc_core {
namespace testing {
Expand All @@ -69,9 +68,7 @@ static void me_delete_from_pollset_set(grpc_endpoint* /*ep*/,

static void me_destroy(grpc_endpoint* ep) {}

static absl::string_view me_get_peer(grpc_endpoint* /*ep*/) {
return "";
}
static absl::string_view me_get_peer(grpc_endpoint* /*ep*/) { return ""; }

static absl::string_view me_get_local_address_unix(grpc_endpoint* /*ep*/) {
return "unix:";
Expand All @@ -82,38 +79,39 @@ static int me_get_fd(grpc_endpoint* /*ep*/) { return -1; }
static bool me_can_track_err(grpc_endpoint* /*ep*/) { return false; }

static const grpc_endpoint_vtable vtable_unix = {me_read,
me_write,
me_add_to_pollset,
me_add_to_pollset_set,
me_delete_from_pollset_set,
me_destroy,
me_get_peer,
me_get_local_address_unix,
me_get_fd,
me_can_track_err};
me_write,
me_add_to_pollset,
me_add_to_pollset_set,
me_delete_from_pollset_set,
me_destroy,
me_get_peer,
me_get_local_address_unix,
me_get_fd,
me_can_track_err};

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

static const grpc_endpoint_vtable vtable_local = {me_read,
me_write,
me_add_to_pollset,
me_add_to_pollset_set,
me_delete_from_pollset_set,
me_destroy,
me_get_peer,
me_get_local_address_local,
me_get_fd,
me_can_track_err};
me_write,
me_add_to_pollset,
me_add_to_pollset_set,
me_delete_from_pollset_set,
me_destroy,
me_get_peer,
me_get_local_address_local,
me_get_fd,
me_can_track_err};

static void check_tsi_security_level(grpc_local_connect_type connect_type,
tsi_security_level level, grpc_endpoint ep) {
tsi_security_level level,
grpc_endpoint ep) {
auto server_creds = grpc_local_server_credentials_create(connect_type);
ChannelArgs args;
EXPECT_NE(server_creds, nullptr);
RefCountedPtr<grpc_server_security_connector> connector = server_creds->
create_security_connector(args);
RefCountedPtr<grpc_server_security_connector> connector =
server_creds->create_security_connector(args);
EXPECT_NE(connector, nullptr);
tsi_peer peer;
CHECK(tsi_construct_peer(0, &peer) == TSI_OK);
Expand All @@ -133,17 +131,17 @@ static void check_tsi_security_level(grpc_local_connect_type connect_type,
//

TEST_F(LocalSecurityConnectorTest, CheckUDSType) {
// auto server_creds = grpc_local_server_credentials_create(LOCAL_TCP);
// auto server_creds = grpc_local_server_credentials_create(LOCAL_TCP);
grpc_endpoint ep = {
.vtable = &vtable_unix,
};
.vtable = &vtable_unix,
};
check_tsi_security_level(UDS, TSI_PRIVACY_AND_INTEGRITY, ep);
}

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

Expand Down
24 changes: 24 additions & 0 deletions tools/run_tests/generated/tests.json

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