Skip to content

Commit

Permalink
STAR-749: Fixed ArrayIndexOutOfBoundsException in FunctionResource#fr…
Browse files Browse the repository at this point in the history
…omName (#168)

The problematic syntax was a function name with empty argument list.

Co-authored-by: kamlesh ghoradkar <[email protected]>
(cherry picked from commit 5d7df12)
(cherry picked from commit 58d49ab)
(cherry picked from commit 2d7c315)
(cherry picked from commit 29fe577)
(cherry picked from commit 92afd91)
  • Loading branch information
jacek-lewandowski committed Oct 18, 2022
1 parent 4df1c57 commit 8984b21
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions test/unit/org/apache/cassandra/auth/FunctionResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,25 @@ public void testFunctionWithoutInputParameter() throws Exception
assertEquals(expected.getKeyspace(), actual.getKeyspace());

String error = "functions/fr_ks/concat is not a valid function resource name. It must end with \"[]\"";
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s",
func,
ks,
name)))
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s",func,ks,name)))
.withMessage(error);
}

@Test
public void testInvalidFunctionName()
{
String expected = "functions_test is not a valid function resource name";
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName("functions_test"))
.withMessage(expected);
assertThatExceptionOfType(IllegalArgumentException.class)
.describedAs(expected)
.isThrownBy(() -> FunctionResource.fromName("functions_test"));
}

@Test
public void testFunctionWithInvalidInput()
{
String expected = String.format("%s/%s/%s[%s]/test is not a valid function resource name", func, ks, name, varType);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s[%s]/test",
func,
ks,
name,
varType)))
.withMessage(expected);
;
assertThatExceptionOfType(IllegalArgumentException.class)
.describedAs(expected)
.isThrownBy(() -> FunctionResource.fromName(String.format("%s/%s/%s[%s]/test", func, ks, name, varType)));
}
}
}

0 comments on commit 8984b21

Please sign in to comment.