blob: d135f46080970825903400a11ccfc46269d481bc [file]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include "utils/uri.h"
#include "absl/status/status.h"
#include "absl/status/status_matchers.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace {
using ::absl_testing::IsOkAndHolds;
using ::absl_testing::StatusIs;
using ::credentio::GetManifestLabelFromAbsoluteUri;
TEST(GetManifestLabelFromAbsoluteUriTest, Success) {
EXPECT_THAT(GetManifestLabelFromAbsoluteUri(
"self#jumbf=/c2pa/foo.bar/c2pa.assertions/blah"),
IsOkAndHolds("foo.bar"));
EXPECT_THAT(GetManifestLabelFromAbsoluteUri("self#jumbf=/c2pa/foo.bar"),
IsOkAndHolds("foo.bar"));
}
TEST(GetManifestLabelFromUriTest, Failure) {
EXPECT_THAT(GetManifestLabelFromAbsoluteUri(""),
StatusIs(absl::StatusCode::kInvalidArgument));
EXPECT_THAT(GetManifestLabelFromAbsoluteUri("/c2pa/foo.bar"),
StatusIs(absl::StatusCode::kInvalidArgument));
EXPECT_THAT(GetManifestLabelFromAbsoluteUri("self#jumbf=/c2pa/"),
StatusIs(absl::StatusCode::kInvalidArgument));
EXPECT_THAT(
GetManifestLabelFromAbsoluteUri("self#jumbf=/c2pa//c2pa.assertions/"),
StatusIs(absl::StatusCode::kInvalidArgument));
}
} // namespace