-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/ev-api
- Loading branch information
Showing
50 changed files
with
1,096 additions
and
377 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cc_library( | ||
name = "helpers", | ||
srcs = ["lib/helpers.cpp"], | ||
hdrs = ["include/everest/staging/helpers/helpers.hpp"], | ||
copts = ["-std=c++17"], | ||
visibility = ["//visibility:public"], | ||
includes = ["include"], | ||
deps = [ | ||
"@com_github_fmtlib_fmt//:fmt", | ||
"@com_github_nlohmann_json//:json", | ||
"//types:types_lib", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# EVerest helper functions | ||
|
||
add_library(everest_staging_helpers STATIC) | ||
add_library(everest::staging::helpers ALIAS everest_staging_helpers) | ||
|
||
target_sources(everest_staging_helpers | ||
PRIVATE | ||
lib/helpers.cpp | ||
) | ||
|
||
target_include_directories(everest_staging_helpers | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
"$<TARGET_PROPERTY:generate_cpp_files,EVEREST_GENERATED_INCLUDE_DIR>" | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
target_link_libraries(everest_staging_helpers | ||
PRIVATE | ||
fmt::fmt | ||
nlohmann_json::nlohmann_json | ||
) | ||
|
||
add_dependencies(everest_staging_helpers generate_cpp_files) | ||
|
||
if (BUILD_TESTING) | ||
add_subdirectory(tests) | ||
endif() |
23 changes: 23 additions & 0 deletions
23
lib/staging/helpers/include/everest/staging/helpers/helpers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#ifndef EVEREST_STAGING_HELPERS_HPP | ||
#define EVEREST_STAGING_HELPERS_HPP | ||
|
||
#include <string> | ||
|
||
namespace types::authorization { | ||
struct ProvidedIdToken; | ||
} | ||
|
||
namespace everest::staging::helpers { | ||
|
||
/// \brief Redacts a provided \p token by hashing it | ||
/// \returns a hashed version of the provided token | ||
std::string redact(const std::string& token); | ||
|
||
types::authorization::ProvidedIdToken redact(const types::authorization::ProvidedIdToken& token); | ||
|
||
} // namespace everest::staging::helpers | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
|
||
#include <everest/staging/helpers/helpers.hpp> | ||
|
||
#include <unordered_map> | ||
|
||
#include <fmt/format.h> | ||
|
||
#include <generated/types/authorization.hpp> | ||
|
||
namespace everest::staging::helpers { | ||
std::string redact(const std::string& token) { | ||
auto hash = std::hash<std::string>{}(token); | ||
return fmt::format("[redacted] hash: {:X}", hash); | ||
} | ||
|
||
types::authorization::ProvidedIdToken redact(const types::authorization::ProvidedIdToken& token) { | ||
types::authorization::ProvidedIdToken redacted_token = token; | ||
redacted_token.id_token.value = redact(redacted_token.id_token.value); | ||
if (redacted_token.parent_id_token.has_value()) { | ||
auto& parent_id_token = redacted_token.parent_id_token.value(); | ||
parent_id_token.value = redact(parent_id_token.value); | ||
} | ||
return redacted_token; | ||
} | ||
} // namespace everest::staging::helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
set(TEST_TARGET_NAME ${PROJECT_NAME}_helpers_tests) | ||
|
||
add_executable(${TEST_TARGET_NAME} | ||
helpers_test.cpp | ||
) | ||
|
||
target_link_libraries(${TEST_TARGET_NAME} | ||
PRIVATE | ||
GTest::gmock_main | ||
GTest::gtest_main | ||
everest::staging::helpers | ||
) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(${TEST_TARGET_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Pionix GmbH and Contributors to EVerest | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
#include <iostream> | ||
|
||
#include <everest/staging/helpers/helpers.hpp> | ||
|
||
using namespace everest::staging::helpers; | ||
using ::testing::StartsWith; | ||
|
||
TEST(HelpersTest, redact_token) { | ||
std::string token = "secret token"; | ||
|
||
auto redacted = redact(token); | ||
|
||
EXPECT_THAT(redacted, StartsWith("[redacted] hash: ")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ PRIVATE | |
date::date | ||
date::date-tz | ||
everest::framework | ||
everest::staging::helpers | ||
) | ||
|
||
# needs c++ 14 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.