Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private CelPolicyConfig parseYaml(String source, String description)
.orElseThrow(
() ->
new CelPolicyValidationException(
String.format("YAML document is malformed: %s", source)));
String.format("YAML document empty or malformed: %s", source)));
node = yamlNode;
} catch (RuntimeException e) {
throw new CelPolicyValidationException("YAML document is malformed: " + e.getMessage(), e);
Expand Down
3 changes: 2 additions & 1 deletion 3 policy/src/main/java/dev/cel/policy/CelPolicyYamlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ private CelPolicy parseYaml() throws CelPolicyValidationException {
.orElseThrow(
() ->
new CelPolicyValidationException(
String.format("YAML document is malformed: %s", policySourceString)));
String.format(
"YAML document empty or malformed: %s", policySourceString)));
node = yamlNode;
} catch (RuntimeException e) {
throw new CelPolicyValidationException("YAML document is malformed: " + e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public final class CelPolicyYamlConfigParserTest {
private static final CelPolicyConfigParser POLICY_CONFIG_PARSER =
CelPolicyParserFactory.newYamlConfigParser();

@Test
public void config_setEmpty() throws Exception {
assertThrows(CelPolicyValidationException.class, () -> POLICY_CONFIG_PARSER.parse(""));
}

@Test
public void config_setBasicProperties() throws Exception {
String yamlConfig = "name: hello\n" + "description: empty\n" + "container: pb.pkg\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public void parseYamlPolicy_success(@TestParameter TestYamlPolicy yamlPolicy) th
assertThat(policy.policySource().getDescription()).isEqualTo(description);
}

@Test
public void parser_setEmpty() throws Exception {
assertThrows(CelPolicyValidationException.class, () -> POLICY_PARSER.parse("", ""));
}

@Test
public void parseYamlPolicy_withExplanation() throws Exception {
String policySource =
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.