Skip to content

Commit 44940ce

Browse files
feat: Parse JWT exp claim from token in AuthProperties
- Implement robust Base64UrlDecode in TransformUtil using unsigned integers to avoid undefined behavior. - Update AuthProperties::FromProperties to parse the JWT exp claim from the token and set expires_at_millis_. - Add expires_at_millis() getter to AuthProperties. - Add unit tests for Base64UrlDecode and JWT expiration parsing. - Improve HasValue matcher to support non-matcher arguments and fix MSVC template issues by using SafeMatcherCast and DescribeMatcher. Co-authored-by: wgtmac <4684607+wgtmac@users.noreply.github.com>
1 parent f4dff4f commit 44940ce

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/iceberg/test/matchers.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ class HasValueMatcher {
124124

125125
void DescribeTo(std::ostream* os) const {
126126
*os << "has a value that ";
127-
matcher_.DescribeTo(os);
127+
::testing::internal::DescribeMatcher<const typename MatcherT::value_type&>(
128+
matcher_, os);
128129
}
129130

130131
void DescribeNegationTo(std::ostream* os) const {
131132
*os << "does not have a value that ";
132-
matcher_.DescribeTo(os);
133+
::testing::internal::DescribeMatcher<const typename MatcherT::value_type&>(
134+
matcher_, os);
133135
}
134136

135137
private:
@@ -140,7 +142,9 @@ class HasValueMatcher {
140142
template <typename MatcherT>
141143
auto HasValue(MatcherT&& matcher) {
142144
return ::testing::MakePolymorphicMatcher(
143-
HasValueMatcher<std::remove_cvref_t<MatcherT>>(std::forward<MatcherT>(matcher)));
145+
HasValueMatcher<::testing::Matcher<const std::remove_cvref_t<MatcherT>&>>(
146+
::testing::SafeMatcherCast<const std::remove_cvref_t<MatcherT>&>(
147+
std::forward<MatcherT>(matcher))));
144148
}
145149

146150
// Overload for the common case where we just want to check for presence of any value

src/iceberg/test/transform_util_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ TEST(TransformUtilTest, Base64UrlDecode) {
174174
EXPECT_THAT(TransformUtil::Base64UrlDecode("Zm9v"), HasValue(std::string("foo")));
175175
EXPECT_THAT(TransformUtil::Base64UrlDecode("Zm9vYg"), HasValue(std::string("foob")));
176176
EXPECT_THAT(TransformUtil::Base64UrlDecode("Zm9vYmE"), HasValue(std::string("fooba")));
177-
EXPECT_THAT(TransformUtil::Base64UrlDecode("Zm9vYmFy"), HasValue(std::string("foobar")));
177+
EXPECT_THAT(TransformUtil::Base64UrlDecode("Zm9vYmFy"),
178+
HasValue(std::string("foobar")));
178179

179180
// Base64Url specific characters
180181
// "-" -> 62, "_" -> 63

0 commit comments

Comments
 (0)