public void MSWOPI_S17_TC14_PutRelativeFile_Fail404()
{
// Get the file URL.
string fileUrl = this.AddFileToSUT(true);
// Get the WOPI URL.
string wopiTargetFileUrl = WopiSutManageCodeControlAdapter.GetWOPIRootResourceUrl(fileUrl, WOPIRootResourceUrlType.FileLevel, TokenAndRequestUrlHelper.DefaultUserName, TokenAndRequestUrlHelper.DefaultPassword, TokenAndRequestUrlHelper.DefaultDomain);
// Get the common header.
WebHeaderCollection commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl);
// Delete the file.
WopiAdapter.DeleteFile(wopiTargetFileUrl, commonHeaders);
// The file has been deleted, so remove it from the clean up list.
this.ExcludeFileFromTheCleanUpProcess(fileUrl);
// Get the common header.
commonHeaders = HeadersHelper.GetCommonHeaders(wopiTargetFileUrl);
byte[] fileContents = Encoding.UTF8.GetBytes("Test Put Relative file.");
string fileName = this.GetUniqueFileNameForPutRelatived();
int statusCode;
try
{
// Create a new file on the WOPI server based on the current file.
WOPIHttpResponse responseOfPutRelativeFile = WopiAdapter.PutRelativeFile(
wopiTargetFileUrl,
commonHeaders,
null,
fileName,
fileContents,
false,
fileContents.Length);
statusCode = responseOfPutRelativeFile.StatusCode;
// Collect the new file for PutRelativeFile.
this.CollectNewAddedFileForPutRelativeFile(fileUrl, fileName);
}
catch (WebException webEx)
{
HttpWebResponse errorResponse = this.GetErrorResponseFromWebException(webEx);
statusCode = this.GetStatusCodeFromHTTPResponse(errorResponse);
}
// Verify MS-WOPI requirement: MS-WOPI_R375
this.Site.CaptureRequirementIfAreEqual(
404,
statusCode,
375,
@"[In PutRelativeFile] Status code ""404"" means ""File unknown/User unauthorized"".");
}