This repository has been archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the ado logic to consume the list of existing items once (#3014)
* update the ado logic to consume the list of existing items once * format * Update src/ApiService/ApiService/onefuzzlib/notifications/Ado.cs Co-authored-by: Teo Voinea <[email protected]> * Adding a notification testing endpoint * fix tests * format * regen docs * update logic * format * fix dummy name * mypy fix * make mypy happy * bandit fix * renaming * address PR Comment --------- Co-authored-by: Teo Voinea <[email protected]>
- Loading branch information
Showing
17 changed files
with
240 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Net; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
|
||
namespace Microsoft.OneFuzz.Service.Functions; | ||
|
||
public class NotificationsTest { | ||
private readonly ILogTracer _log; | ||
private readonly IEndpointAuthorization _auth; | ||
private readonly IOnefuzzContext _context; | ||
|
||
public NotificationsTest(ILogTracer log, IEndpointAuthorization auth, IOnefuzzContext context) { | ||
_log = log; | ||
_auth = auth; | ||
_context = context; | ||
} | ||
|
||
private async Async.Task<HttpResponseData> Post(HttpRequestData req) { | ||
_log.WithTag("HttpRequest", "GET").Info($"Notification test"); | ||
var request = await RequestHandling.ParseRequest<NotificationTest>(req); | ||
if (!request.IsOk) { | ||
return await _context.RequestHandling.NotOk(req, request.ErrorV, "notification search"); | ||
} | ||
|
||
var notificationTest = request.OkV; | ||
var result = await _context.NotificationOperations.TriggerNotification(notificationTest.Notification.Container, notificationTest.Notification, | ||
notificationTest.Report, isLastRetryAttempt: true); | ||
var response = req.CreateResponse(HttpStatusCode.OK); | ||
await response.WriteAsJsonAsync(new NotificationTestResponse(result.IsOk, result.ErrorV?.ToString())); | ||
return response; | ||
} | ||
|
||
|
||
[Function("NotificationsTest")] | ||
public Async.Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Anonymous, "POST", Route = "notifications/test")] HttpRequestData req) { | ||
return _auth.CallIfUser(req, r => r.Method switch { | ||
"POST" => Post(r), | ||
_ => throw new InvalidOperationException("Unsupported HTTP method"), | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.