public async Task CreateCommentOnUnknownResource() { CreateCommentResult comment = await VirusTotal.CreateCommentAsync(TestData.GetRandomSHA1s(1).First(), "VirusTotal.NET test - " + DateTime.UtcNow.ToString("O")); Assert.Equal(CommentResponseCode.Error, comment.ResponseCode); Assert.Equal("Could not find resource", comment.VerboseMsg); }
public async Task CreateValidComment() { CreateCommentResult comment = await VirusTotal.CreateCommentAsync(TestData.TestHash, "VirusTotal.NET test - " + DateTime.UtcNow.ToString("O")); Assert.Equal(CommentResponseCode.Success, comment.ResponseCode); Assert.Equal("Your comment was successfully posted", comment.VerboseMsg); }
public async Task <CreateCommentResult> CreateCommentAsync(Comment newComment) { CreateCommentResult createCommentResult = new CreateCommentResult() { NewComment = null }; if (newComment.Content.Length < _appSettings.Shout_MinLength) { createCommentResult.State = CreateShoutState.ContentTooSmall; return(createCommentResult); } if (newComment.Content.Length > _appSettings.Shout_MaxLength) { createCommentResult.State = CreateShoutState.ContentTooLong; return(createCommentResult); } newComment.Content = this._sanitizerService.SanitizeHTML(newComment.Content); newComment.Content = await this._badWordsService.CleanAsync(newComment.Content); newComment.Id = await this._shoutStore.CreateCommentAsync(newComment); newComment.ShoutId = newComment.ShoutId; newComment.UserId = newComment.UserId; newComment.CreateDate = DateTime.UtcNow; createCommentResult.State = CreateShoutState.Success; createCommentResult.NewComment = newComment; return(createCommentResult); }
public async Task CreateDuplicateComment() { //Create the comment. This might fail with an error, but it does not matter. await VirusTotal.CreateCommentAsync(TestData.TestHash, "VirusTotal.NET test"); CreateCommentResult comment = await VirusTotal.CreateCommentAsync(TestData.TestHash, "VirusTotal.NET test"); Assert.Equal(CommentResponseCode.Error, comment.ResponseCode); Assert.Equal("Duplicate comment", comment.VerboseMsg); }
public async Task C2_outbound(string api_key, string sha1, string upload_to_vt) { VirusTotal virusTotal = new VirusTotal(api_key); virusTotal.UseTLS = true; CreateCommentResult comment = await virusTotal.CreateCommentAsync(sha1, upload_to_vt); Assert.Equal(CommentResponseCode.Error, comment.ResponseCode); }
private StreamComment CreateComment(String text, String contentKey, String contentRecordType, String commentListKey, int principalCommentId) { try { CommentApi commentApi = new CommentApi(session.GetApiClient()); CommentV2Record commentRecord = new CommentV2Record(); commentRecord.ContentKey = contentKey; if (principalCommentId > 0) { commentRecord.CommentPID = principalCommentId; } if (commentListKey != null) { commentRecord.CommentListKey = commentListKey; } commentRecord.Text = text; CreateCommentInput createCommentInput = new CreateCommentInput(contentKey, commentRecord); CreateCommentResult createCommentResult = commentApi.CreateComment(createCommentInput); if (createCommentResult.Hdr.Rc == 0) { CommentV2Record createdComment = createCommentResult.Comment; StreamComment comment = new StreamComment(createdComment, contentRecordType); return(comment); } else { throw new Exception("Error creating comment. Rc=" + createCommentResult.Hdr.Rc); } } catch (Exception ex) { throw new Exception("Error creating comment", ex); } }