Skip to content
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
8 changes: 4 additions & 4 deletions src/SlimFaas/Endpoints/JobEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static partial class JobEndpoints

private static bool IsValidFunctionName(string functionName, ILogger logger)
{
if (functionName.Length < 3 || functionName.Length > 12 || !FunctionNamePattern().IsMatch(functionName))
if (functionName.Length < 3 || functionName.Length > 30 || !FunctionNamePattern().IsMatch(functionName))
{
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 12 characters", functionName);
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 30 characters", functionName);
return false;
}
return true;
Expand Down Expand Up @@ -67,7 +67,7 @@ private static async Task<IResult> CreateJob(

if (!IsValidFunctionName(functionName, logger))
{
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
}

CreateJob? createJob = await context.Request.ReadFromJsonAsync(
Expand Down Expand Up @@ -124,7 +124,7 @@ private static async Task<IResult> DeleteJob(

if (!IsValidFunctionName(functionName, logger))
{
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
}

bool isMessageComeFromNamespaceInternal =
Expand Down
8 changes: 4 additions & 4 deletions src/SlimFaas/Endpoints/JobScheduleEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public static partial class JobScheduleEndpoints

private static bool IsValidFunctionName(string functionName, ILogger logger)
{
if (functionName.Length < 3 || functionName.Length > 12 || !FunctionNamePattern().IsMatch(functionName))
if (functionName.Length < 3 || functionName.Length > 30 || !FunctionNamePattern().IsMatch(functionName))
{
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 12 characters", functionName);
logger.LogWarning("Invalid function name: {FunctionName}. Must match pattern [a-z0-9_-] and be between 3 and 30 characters", functionName);
return false;
}
return true;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static async Task<IResult> CreateScheduleJob(

if (!IsValidFunctionName(functionName, logger))
{
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
}

if (scheduleJobService == null)
Expand Down Expand Up @@ -148,7 +148,7 @@ private static async Task<IResult> DeleteScheduleJob(

if (!IsValidFunctionName(functionName, logger))
{
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 12 characters");
return Results.BadRequest("Function name must match pattern [a-z0-9_-] and be between 3 and 30 characters");
}

bool isMessageComeFromNamespaceInternal =
Expand Down
5 changes: 3 additions & 2 deletions tests/SlimFaas.Tests/Jobs/JobEndpointsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public async Task RunJob_Returns_expected_status(string path,

[Theory(DisplayName = "POST /job/{name} – retourne 400 si le nom de fonction est invalide")]
[InlineData("/job/ab")]
[InlineData("/job/abcdefghijklm")]
[InlineData("/job/abcdefghijklmnopqrstuvwxyz12345")]
[InlineData("/job/test.func")]
[InlineData("/job/test func")]
[InlineData("/job/test@func")]
Expand Down Expand Up @@ -130,6 +130,7 @@ public async Task CreateJob_Returns_400_When_FunctionName_Invalid(string path)
[Theory(DisplayName = "POST /job/{name} – accepte les noms valides")]
[InlineData("/job/abc")]
[InlineData("/job/abcdefghijkl")]
[InlineData("/job/abcdefghijklmnopqrstuvwxyz1234")]
[InlineData("/job/test-func")]
[InlineData("/job/my-app")]
[InlineData("/job/daisy")]
Expand Down Expand Up @@ -225,7 +226,7 @@ public async Task DeleteJob_Returns_expected_status(string path,

[Theory(DisplayName = "DELETE /job/{name}/{id} – retourne 400 si le nom de fonction est invalide")]
[InlineData("/job/ab/123")]
[InlineData("/job/abcdefghijklm/123")]
[InlineData("/job/abcdefghijklmnopqrstuvwxyz12345/123")]
public async Task DeleteJob_Returns_400_When_FunctionName_Invalid(string path)
{
(IHost host, Mock<IJobService> jobSvc, _) = await BuildHostAsync(jobServiceMock =>
Expand Down
5 changes: 3 additions & 2 deletions tests/SlimFaas.Tests/Jobs/JobScheduleEndpointsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ await BuildHostAsync(svc =>

[Theory(DisplayName = "POST /job-schedules/{name} – retourne 400 si le nom de fonction est invalide")]
[InlineData("/job-schedules/ab")]
[InlineData("/job-schedules/abcdefghijklm")]
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz12345")]
[InlineData("/job-schedules/test.func")]
[InlineData("/job-schedules/test func")]
[InlineData("/job-schedules/test@func")]
Expand Down Expand Up @@ -166,6 +166,7 @@ await BuildHostAsync(svc =>
[Theory(DisplayName = "POST /job-schedules/{name} – accepte les noms valides")]
[InlineData("/job-schedules/abc")]
[InlineData("/job-schedules/abcdefghijkl")]
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz1234")]
[InlineData("/job-schedules/test-func")]
[InlineData("/job-schedules/my-app")]
[InlineData("/job-schedules/daisy")]
Expand Down Expand Up @@ -276,7 +277,7 @@ await BuildHostAsync(svc =>

[Theory(DisplayName = "DELETE /job-schedules/{name}/{id} – retourne 400 si le nom de fonction est invalide")]
[InlineData("/job-schedules/ab/sid")]
[InlineData("/job-schedules/abcdefghijklm/sid")]
[InlineData("/job-schedules/abcdefghijklmnopqrstuvwxyz12345/sid")]
public async Task DeleteSchedule_Returns_400_When_FunctionName_Invalid(string path)
{
(IHost host, Mock<IScheduleJobService> schedSvc, _) =
Expand Down
Loading