Skip to content

Commit de1791a

Browse files
Copilotbbockelm
andcommitted
Fix lint issues: remove trailing whitespace and reformat lines
Co-authored-by: bbockelm <1093447+bbockelm@users.noreply.github.com>
1 parent ca69f6c commit de1791a

File tree

2 files changed

+31
-25
lines changed

2 files changed

+31
-25
lines changed

src/scitokens_internal.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,34 @@ constexpr size_t MAX_ISSUER_MUTEXES = 1000;
4242
// Get or create a mutex for a specific issuer
4343
std::shared_ptr<std::mutex> get_issuer_mutex(const std::string &issuer) {
4444
std::lock_guard<std::mutex> guard(issuer_mutex_map_lock);
45-
45+
4646
auto it = issuer_mutexes.find(issuer);
4747
if (it != issuer_mutexes.end()) {
4848
return it->second;
4949
}
50-
50+
5151
// Prevent resource exhaustion: limit the number of cached mutexes
5252
if (issuer_mutexes.size() >= MAX_ISSUER_MUTEXES) {
5353
// Remove mutexes that are no longer in use
5454
// Since we hold issuer_mutex_map_lock, no other thread can acquire
5555
// a reference to these mutexes, making this check safe
56-
for (auto iter = issuer_mutexes.begin(); iter != issuer_mutexes.end(); ) {
56+
for (auto iter = issuer_mutexes.begin();
57+
iter != issuer_mutexes.end();) {
5758
if (iter->second.use_count() == 1) {
5859
// Only we hold a reference, safe to remove
5960
iter = issuer_mutexes.erase(iter);
6061
} else {
6162
++iter;
6263
}
6364
}
64-
65+
6566
// If still at capacity after cleanup, fail rather than unbounded growth
6667
if (issuer_mutexes.size() >= MAX_ISSUER_MUTEXES) {
67-
throw std::runtime_error("Too many concurrent issuers - resource exhaustion prevented");
68+
throw std::runtime_error(
69+
"Too many concurrent issuers - resource exhaustion prevented");
6870
}
6971
}
70-
72+
7173
auto mutex_ptr = std::make_shared<std::mutex>();
7274
issuer_mutexes[issuer] = mutex_ptr;
7375
return mutex_ptr;
@@ -872,8 +874,9 @@ Validator::get_public_key_pem(const std::string &issuer, const std::string &kid,
872874
// Use per-issuer lock to prevent thundering herd for new issuers
873875
auto issuer_mutex = get_issuer_mutex(issuer);
874876
std::lock_guard<std::mutex> lock(*issuer_mutex);
875-
876-
// Check again if keys are now in DB (another thread may have fetched them)
877+
878+
// Check again if keys are now in DB (another thread may have fetched
879+
// them)
877880
if (get_public_keys_from_db(issuer, now, result->m_keys,
878881
result->m_next_update)) {
879882
// Keys are now available, use them

test/main.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ TEST_F(SerializeTest, ExplicitTime) {
504504

505505
TEST_F(SerializeTest, GetExpirationErrorHandling) {
506506
char *err_msg = nullptr;
507-
507+
508508
// Test NULL token handling
509509
long long expiry;
510510
auto rv = scitoken_get_expiration(nullptr, &expiry, &err_msg);
@@ -513,27 +513,28 @@ TEST_F(SerializeTest, GetExpirationErrorHandling) {
513513
EXPECT_STREQ(err_msg, "Token cannot be NULL");
514514
free(err_msg);
515515
err_msg = nullptr;
516-
517-
// Test NULL expiry parameter handling
516+
517+
// Test NULL expiry parameter handling
518518
rv = scitoken_get_expiration(m_token.get(), nullptr, &err_msg);
519519
ASSERT_FALSE(rv == 0);
520520
ASSERT_TRUE(err_msg != nullptr);
521521
EXPECT_STREQ(err_msg, "Expiry output parameter cannot be NULL");
522522
free(err_msg);
523523
err_msg = nullptr;
524-
524+
525525
// Test normal operation works
526526
char *token_value = nullptr;
527527
rv = scitoken_serialize(m_token.get(), &token_value, &err_msg);
528528
ASSERT_TRUE(rv == 0) << err_msg;
529-
530-
rv = scitoken_deserialize_v2(token_value, m_read_token.get(), nullptr, &err_msg);
529+
530+
rv = scitoken_deserialize_v2(token_value, m_read_token.get(), nullptr,
531+
&err_msg);
531532
ASSERT_TRUE(rv == 0) << err_msg;
532-
533+
533534
rv = scitoken_get_expiration(m_read_token.get(), &expiry, &err_msg);
534535
ASSERT_TRUE(rv == 0) << err_msg;
535536
ASSERT_TRUE(expiry > 0);
536-
537+
537538
free(token_value);
538539
}
539540

@@ -725,7 +726,8 @@ TEST_F(KeycacheTest, SetGetTest) {
725726
TEST_F(KeycacheTest, SetGetConfiguredCacheHome) {
726727
// Set cache home
727728
char cache_path[FILENAME_MAX];
728-
ASSERT_TRUE(getcwd(cache_path, sizeof(cache_path)) != nullptr); // Side effect gets cwd
729+
ASSERT_TRUE(getcwd(cache_path, sizeof(cache_path)) !=
730+
nullptr); // Side effect gets cwd
729731
char *err_msg = nullptr;
730732
std::string key = "keycache.cache_home";
731733

@@ -944,30 +946,31 @@ TEST_F(IssuerSecurityTest, SpecialCharacterIssuer) {
944946
// Test for thundering herd prevention with per-issuer locks
945947
TEST_F(IssuerSecurityTest, ThunderingHerdPrevention) {
946948
char *err_msg = nullptr;
947-
949+
948950
// Create tokens for a new issuer and pre-populate the cache
949951
std::string test_issuer = "https://thundering-herd-test.example.org/gtest";
950-
952+
951953
auto rv = scitoken_set_claim_string(m_token.get(), "iss",
952954
test_issuer.c_str(), &err_msg);
953955
ASSERT_TRUE(rv == 0) << err_msg;
954-
956+
955957
// Store public key for this issuer in the cache
956958
rv = scitoken_store_public_ec_key(test_issuer.c_str(), "1", ec_public,
957959
&err_msg);
958960
ASSERT_TRUE(rv == 0) << err_msg;
959-
961+
960962
char *token_value = nullptr;
961963
rv = scitoken_serialize(m_token.get(), &token_value, &err_msg);
962964
ASSERT_TRUE(rv == 0) << err_msg;
963965
std::unique_ptr<char, decltype(&free)> token_value_ptr(token_value, free);
964-
965-
// Successfully deserialize - the per-issuer lock should prevent thundering herd
966-
// Since we pre-populated the cache, this should succeed without network access
966+
967+
// Successfully deserialize - the per-issuer lock should prevent thundering
968+
// herd Since we pre-populated the cache, this should succeed without
969+
// network access
967970
rv = scitoken_deserialize_v2(token_value, m_read_token.get(), nullptr,
968971
&err_msg);
969972
ASSERT_TRUE(rv == 0) << err_msg;
970-
973+
971974
// Verify the issuer claim
972975
char *value;
973976
rv = scitoken_get_claim_string(m_read_token.get(), "iss", &value, &err_msg);

0 commit comments

Comments
 (0)