Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 1 | /* |
| 2 | Copyright (c) 2018-2019 Nokia. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
Timo Tietavainen | a0745d2 | 2019-11-28 09:55:22 +0200 | [diff] [blame] | 17 | /* |
| 18 | * This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 19 | * platform project (RICP). |
| 20 | */ |
| 21 | |
Rolf Badorek | ef2bf51 | 2019-08-20 11:17:15 +0300 | [diff] [blame] | 22 | #include <gtest/gtest.h> |
| 23 | #include "private/namespacevalidator.hpp" |
| 24 | #include <sdl/invalidnamespace.hpp> |
| 25 | #include <sdl/emptynamespace.hpp> |
| 26 | |
| 27 | using namespace shareddatalayer; |
| 28 | |
| 29 | TEST(NamespaceValidatorTest, CanGetDisallowedCharactersInNamespace) |
| 30 | { |
| 31 | EXPECT_EQ(",{}", getDisallowedCharactersInNamespace()); |
| 32 | } |
| 33 | |
| 34 | TEST(NamespaceValidatorTest, CanAcceptValidNamespaceSyntax) |
| 35 | { |
| 36 | EXPECT_TRUE(isValidNamespaceSyntax("someValidNamespace")); |
| 37 | EXPECT_TRUE(isValidNamespaceSyntax("")); |
| 38 | } |
| 39 | |
| 40 | TEST(ValidateNamespaceTest, CanDetectDisallowedCharactersInNamespaceSyntax) |
| 41 | { |
| 42 | EXPECT_FALSE(isValidNamespaceSyntax("some,IllegalNamespace")); |
| 43 | EXPECT_FALSE(isValidNamespaceSyntax("someIllegal{Namespace")); |
| 44 | EXPECT_FALSE(isValidNamespaceSyntax("someIllegalNamespace}")); |
| 45 | } |
| 46 | |
| 47 | TEST(NamespaceValidatorTest, CanAcceptValidNamespace) |
| 48 | { |
| 49 | EXPECT_NO_THROW(validateNamespace("someValidNamespace")); |
| 50 | EXPECT_TRUE(isValidNamespace("someValidNamespace")); |
| 51 | } |
| 52 | |
| 53 | TEST(NamespaceValidatorTest, WillNotAcceptEmptyNamespace) |
| 54 | { |
| 55 | EXPECT_THROW(validateNamespace(""), EmptyNamespace); |
| 56 | EXPECT_FALSE(isValidNamespace("")); |
| 57 | } |
| 58 | |
| 59 | TEST(NamespaceValidatorTest, WillNotAcceptNamespaceContainingDisallowedCharacters) |
| 60 | { |
| 61 | EXPECT_THROW(validateNamespace("some,IllegalNamespace"), InvalidNamespace); |
| 62 | EXPECT_FALSE(isValidNamespace("some,IllegalNamespace")); |
| 63 | EXPECT_THROW(validateNamespace("someIllegal{Namespace}"), InvalidNamespace); |
| 64 | EXPECT_FALSE(isValidNamespace("someIllegal{Namespace}")); |
| 65 | EXPECT_THROW(validateNamespace("some,Illegal{Namespace}"), InvalidNamespace); |
| 66 | EXPECT_FALSE(isValidNamespace("some,Illegal{Namespace}")); |
| 67 | } |