-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebDAV System Module #21106
Open
SHBBusinessSolutions
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
SHBBusinessSolutions:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WebDAV System Module #21106
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
471042d
Readme
JulianTillmann ee64719
Merge pull request #1 from microsoft/main
JulianTillmann 0b6f586
Prototype
JulianTillmann 270947a
Test Automation + Bugfixes
JulianTillmann 2d96efa
Adapted Suggestions by PeterConijn
JulianTillmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"id": "ff0caa38-65a2-49c5-a7e2-6a0475cfc60e", | ||
"name": "SharePoint Test Library", | ||
"publisher": "Microsoft", | ||
"version": "21.4.0.0", | ||
"brief": "Test libraries for the SharePoint module", | ||
"description": "Provides a set of AL functionality and Helper libraries to make use of SharePoint REST API", | ||
"privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009", | ||
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", | ||
"help": "https://go.microsoft.com/fwlink/?linkid=2103698", | ||
"url": "https://go.microsoft.com/fwlink/?linkid=724011", | ||
"logo": "", | ||
"dependencies": [ | ||
{ | ||
"id": "199527d2-53dd-48e1-8732-8850d4f9e45b", | ||
"name": "WebDAV", | ||
"publisher": "Microsoft", | ||
"version": "21.4.0.0" | ||
} | ||
], | ||
"screenshots": [ | ||
|
||
], | ||
"features": [ | ||
|
||
], | ||
"platform": "21.0.0.0", | ||
"idRanges": [ | ||
{ | ||
"from": 135678, | ||
"to": 135689 | ||
} | ||
], | ||
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2206603", | ||
"resourceExposurePolicy": { | ||
"allowDebugging": true, | ||
"allowDownloadingSource": true, | ||
"includeSourceInSymbolFile": true | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Modules/System Test Libraries/WebDAV/src/WebDAVDummyAuthorization.Codeunit.al
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,12 @@ | ||
// ------------------------------------------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
// ------------------------------------------------------------------------------------------------ | ||
|
||
codeunit 135679 "Dummy WebDAV Authorization" implements "WebDAV Authorization" | ||
{ | ||
procedure Authorize(var HttpRequestMessage: HttpRequestMessage); | ||
begin | ||
// Does nothing | ||
end; | ||
} |
204 changes: 204 additions & 0 deletions
204
Modules/System Test Libraries/WebDAV/src/WebDAVTestLibrary.Codeunit.al
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,204 @@ | ||
codeunit 136789 "WebDAV Test Library" | ||
{ | ||
EventSubscriberInstance = Manual; | ||
|
||
var | ||
RequestMessage: HttpRequestMessage; | ||
|
||
[EventSubscriber(ObjectType::Codeunit, Codeunit::"WebDAV Request Helper", 'OnBeforeSendRequest', '', false, false)] | ||
local procedure RunOnBeforeSendRequest(HttpRequestMessage: HttpRequestMessage; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response"; var IsHandled: Boolean; Method: Text) | ||
var | ||
HttpHeaders: HttpHeaders; | ||
Uri: Text; | ||
begin | ||
IsHandled := true; | ||
RequestMessage := HttpRequestMessage; | ||
HttpRequestMessage.GetHeaders(HttpHeaders); | ||
Uri := HttpRequestMessage.GetRequestUri; | ||
|
||
case HttpRequestMessage.Method of | ||
'PROPFIND': | ||
begin | ||
if HttpHeaders.Contains('Depth') then | ||
if GetDepth(HttpHeaders) then | ||
GetPropfindRecursiveResponse(Uri, WebDAVOperationResponse) | ||
else | ||
GetPropfindResponse(Uri, WebDAVOperationResponse); | ||
end; | ||
'MKCOL': | ||
GetCreatedResponse(Uri, WebDAVOperationResponse); | ||
'GET': | ||
GetResponseText(Uri, WebDAVOperationResponse); | ||
'COPY': | ||
GetSuccessfullResponse(Uri, WebDAVOperationResponse); | ||
'MOVE': | ||
GetSuccessfullResponse(Uri, WebDAVOperationResponse); | ||
'DELETE': | ||
GetSuccessfullResponse(Uri, WebDAVOperationResponse); | ||
'PUT': | ||
GetSuccessfullResponse(Uri, WebDAVOperationResponse); | ||
else | ||
Error('No matching test response for %1', Uri); | ||
end; | ||
end; | ||
|
||
procedure GetRequestMessage(): HttpRequestMessage | ||
begin | ||
exit(RequestMessage); | ||
end; | ||
|
||
local procedure GetCreatedResponse(Uri: Text; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response") | ||
var | ||
HttpHeaders: HttpHeaders; | ||
begin | ||
WebDAVOperationResponse.SetHttpResponse('', HttpHeaders, 201, true, 'Created'); | ||
end; | ||
|
||
local procedure GetResponseText(Uri: Text; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response") | ||
var | ||
HttpHeaders: HttpHeaders; | ||
begin | ||
WebDAVOperationResponse.SetHttpResponse('This is a test string.', HttpHeaders, 400, true, ''); | ||
end; | ||
|
||
local procedure GetSuccessfullResponse(Uri: Text; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response") | ||
var | ||
HttpHeaders: HttpHeaders; | ||
begin | ||
WebDAVOperationResponse.SetHttpResponse('', HttpHeaders, 400, true, ''); | ||
end; | ||
|
||
local procedure GetPropfindResponse(Uri: Text; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response") | ||
var | ||
HttpHeaders: HttpHeaders; | ||
ResponseContent: TextBuilder; | ||
begin | ||
ResponseContent.AppendLine('<?xml version="1.0" encoding="utf-8"?>'); | ||
ResponseContent.AppendLine('<D:multistatus xmlns:D="DAV:">'); | ||
|
||
// Folders = 4; Files = 33 | ||
// Uri Folder | ||
AddPropfindFolder(ResponseContent, Uri, GetLastUrlItemName(Uri), 'Sun, 01 Jan 2023 12:00:00 GMT', 'Sun, 01 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'index.html', 'text/html', 123, 'Sun, 01 Jan 2023 12:01:01 GMT', 'Sun, 01 Jan 2023 12:01:01 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'logo.png', 'image/png', 4567, 'Sun, 01 Jan 2023 12:02:02 GMT', 'Sun, 01 Jan 2023 12:02:02 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'response.xml', 'text/xml', 890, 'Sun, 01 Jan 2023 12:03:03 GMT', 'Sun, 01 Jan 2023 12:03:03 GMT'); | ||
|
||
// Folder1 | ||
AddPropfindFolder(ResponseContent, Uri, '/Folder1', 'Mon, 02 Jan 2023 12:00:00 GMT', 'Mon, 02 Jan 2023 12:00:00 GMT'); | ||
// Folder2 | ||
AddPropfindFolder(ResponseContent, Uri, 'Folder2', 'Fri, 06 Jan 2023 12:00:00 GMT', 'Fri, 06 Jan 2023 12:00:00 GMT'); | ||
// Folder3 | ||
AddPropfindFolder(ResponseContent, Uri, 'Folder3', 'Mon, 09 Jan 2023 12:00:00 GMT', 'Mon, 09 Jan 2023 12:00:00 GMT'); | ||
|
||
ResponseContent.AppendLine('</D:multistatus>'); | ||
WebDAVOperationResponse.SetHttpResponse(ResponseContent.ToText(), HttpHeaders, 400, true, ''); | ||
end; | ||
|
||
local procedure GetPropfindRecursiveResponse(Uri: Text; var WebDAVOperationResponse: Codeunit "WebDAV Operation Response") | ||
var | ||
HttpHeaders: HttpHeaders; | ||
ResponseContent: TextBuilder; | ||
begin | ||
ResponseContent.AppendLine('<?xml version="1.0" encoding="utf-8"?>'); | ||
ResponseContent.AppendLine('<D:multistatus xmlns:D="DAV:">'); | ||
|
||
// Folders = 10; Files = 13 | ||
// Uri Folder | ||
AddPropfindFolder(ResponseContent, Uri, GetLastUrlItemName(Uri), 'Sun, 01 Jan 2023 12:00:00 GMT', 'Sun, 01 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'index.html', 'text/html', 123, 'Sun, 01 Jan 2023 12:01:01 GMT', 'Sun, 01 Jan 2023 12:01:01 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'logo.png', 'image/png', 4567, 'Sun, 01 Jan 2023 12:02:02 GMT', 'Sun, 01 Jan 2023 12:02:02 GMT'); | ||
AddPropFindFile(ResponseContent, Uri, 'response.xml', 'text/xml', 890, 'Sun, 01 Jan 2023 12:03:03 GMT', 'Sun, 01 Jan 2023 12:03:03 GMT'); | ||
|
||
// Folder1 | ||
AddPropfindFolder(ResponseContent, Uri, '/Folder1', 'Mon, 02 Jan 2023 12:00:00 GMT', 'Mon, 02 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1', 'pic.jpg', 'image/jpeg', 4666, 'Mon, 02 Jan 2023 13:13:13 GMT', 'Mon, 02 Jan 2023 13:13:13 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1', 'pic.gif', 'image/gif', 466, 'Mon, 02 Jan 2023 14:14:14 GMT', 'Mon, 02 Jan 2023 14:14:14 GMT'); | ||
// Folder1/Subfolder1 | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder1', 'SubFolder1', 'Tue, 03 Jan 2023 12:00:00 GMT', 'Tue, 03 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1/Subfolder1', 'file1.txt', 'text/plain', 21, 'Tue, 03 Jan 2023 13:13:13 GMT', 'Tue, 03 Jan 2023 13:13:13 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1/Subfolder1', 'file2.txt', 'text/plain', 500, 'Tue, 03 Jan 2023 15:06:59 GMT', 'Tue, 03 Jan 2023 15:06:59 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1/Subfolder1', 'file3.txt', 'text/plain', 33, 'Tue, 03 Jan 2023 00:00:00 GMT', 'Tue, 03 Jan 2023 00:00:00 GMT'); | ||
// Folder1/Subfolder2 | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder1', 'SubFolder2', 'Wed, 04 Jan 2023 12:00:00 GMT', 'Wed, 04 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1/Subfolder2', 'file1.pdf', 'application/pdf', 53950, 'Wed, 04 Jan 2023 23:59:59 GMT', 'Wed, 04 Jan 2023 23:59:59 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder1/Subfolder2', 'file2.fob', 'application/octet-stream', 373137165, 'Wed, 04 Jan 2023 11:59:59 GMT', 'Wed, 04 Jan 2023 11:59:59 GMT'); | ||
// Folder1/Subfolder3 | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder1', 'SubFolder3', 'Thu, 05 Jan 2023 12:00:00 GMT', 'Thu, 05 Jan 2023 12:00:00 GMT'); | ||
// Folder2 | ||
AddPropfindFolder(ResponseContent, Uri, 'Folder2', 'Fri, 06 Jan 2023 12:00:00 GMT', 'Fri, 06 Jan 2023 12:00:00 GMT'); | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder2', 'SubFolder1', 'Sat, 07 Jan 2023 12:00:00 GMT', 'Sat, 07 Jan 2023 12:00:00 GMT'); | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder2/SubFolder1', 'SubSubFolder1', 'Sat, 07 Jan 2023 20:00:00 GMT', 'Sat, 07 Jan 2023 20:00:00 GMT'); | ||
AddPropfindFolder(ResponseContent, Uri + '/Folder2', 'SubFolder2', 'Sun, 08 Jan 2023 12:00:00 GMT', 'Sun, 08 Jan 2023 12:00:00 GMT'); | ||
// Folder3 | ||
AddPropfindFolder(ResponseContent, Uri, 'Folder3', 'Mon, 09 Jan 2023 12:00:00 GMT', 'Mon, 09 Jan 2023 12:00:00 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder3', 'file1.txt', 'text/plain', 21, 'Mon, 09 Jan 2023 13:13:13 GMT', 'Sun, 31 Dec 2023 23:59:59 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder3', 'file2.txt', 'text/plain', 500, 'Mon, 09 Jan 2023 15:06:59 GMT', 'Mon, 09 Jan 2023 15:06:59 GMT'); | ||
AddPropFindFile(ResponseContent, Uri + '/Folder3', 'file3.txt', 'text/plain', 33, 'Mon, 09 Jan 2023 00:00:00 GMT', 'Mon, 09 Jan 2023 00:00:00 GMT'); | ||
|
||
ResponseContent.AppendLine('</D:multistatus>'); | ||
WebDAVOperationResponse.SetHttpResponse(ResponseContent.ToText(), HttpHeaders, 400, true, ''); | ||
end; | ||
|
||
|
||
local procedure AddPropfindFolder(var ResponseContent: TextBuilder; Uri: Text; FolderName: Text; CreationDate: Text; LastModifiedDate: Text) | ||
begin | ||
ResponseContent.AppendLine('<D:response>'); | ||
ResponseContent.AppendLine(StrSubstNo('<D:href>%1</D:href>', Uri + '/' + FolderName)); | ||
ResponseContent.AppendLine('<D:propstat>'); | ||
ResponseContent.AppendLine('<D:status>HTTP/1.1 200 OK</D:status>'); | ||
ResponseContent.AppendLine('<D:prop>'); | ||
ResponseContent.AppendLine('<D:getcontenttype/>'); | ||
ResponseContent.AppendLine(StrSubstNo('<D:getlastmodified>%1</D:getlastmodified>', LastModifiedDate)); | ||
ResponseContent.AppendLine(StrSubstNo('<D:displayname>%1</D:displayname>', FolderName)); | ||
ResponseContent.AppendLine('<D:getcontentlength>0</D:getcontentlength>'); | ||
ResponseContent.AppendLine(StrSubstNo('<D:creationdate>%1</D:creationdate>', CreationDate)); | ||
ResponseContent.AppendLine('<D:resourcetype>'); | ||
ResponseContent.AppendLine('<D:collection/>'); | ||
ResponseContent.AppendLine('</D:resourcetype>'); | ||
ResponseContent.AppendLine('</D:prop>'); | ||
ResponseContent.AppendLine('</D:propstat>'); | ||
ResponseContent.AppendLine('</D:response>'); | ||
end; | ||
|
||
local procedure AddPropfindFile(var ResponseContent: TextBuilder; Uri: Text; FileName: Text; ContentType: Text; ContentLength: Integer; CreationDate: Text; LastModifiedDate: Text) | ||
begin | ||
ResponseContent.AppendLine('<D:response>'); | ||
ResponseContent.AppendLine(StrSubstNo('<D:href>%1</D:href>', Uri + '/' + Filename)); | ||
ResponseContent.AppendLine('<D:propstat>'); | ||
ResponseContent.AppendLine('<D:status>HTTP/1.1 200 OK</D:status>'); | ||
ResponseContent.AppendLine('<D:prop>'); | ||
ResponseContent.AppendLine(StrSubstNo('<D:getcontenttype>%1</D:getcontenttype>', ContentType)); | ||
ResponseContent.AppendLine(StrSubstNo('<D:getlastmodified>%1</D:getlastmodified>', LastModifiedDate)); | ||
ResponseContent.AppendLine(StrSubstNo('<D:displayname>%1</D:displayname>', Filename)); | ||
ResponseContent.AppendLine(StrSubstNo('<D:getcontentlength>%1</D:getcontentlength>', ContentLength)); | ||
ResponseContent.AppendLine(StrSubstNo('<D:creationdate>%1</D:creationdate>', CreationDate)); | ||
ResponseContent.AppendLine('<D:resourcetype/>'); | ||
ResponseContent.AppendLine('</D:prop>'); | ||
ResponseContent.AppendLine('</D:propstat>'); | ||
ResponseContent.AppendLine('</D:response>'); | ||
end; | ||
|
||
local procedure GetLastUrlItemName(Uri: Text) LastUriItemName: Text; | ||
var | ||
UriParts: List of [Text]; | ||
begin | ||
UriParts := Uri.Split('/'); | ||
UriParts.Get(UriParts.Count, LastUriItemName); | ||
end; | ||
|
||
local procedure GetDepth(HttpHeaders: HttpHeaders) IsRecursive: Boolean; | ||
var | ||
Values: List of [Text]; | ||
begin | ||
HttpHeaders.GetValues('Depth', Values); | ||
case Values.Get(1) of | ||
'infinity': | ||
exit(true); | ||
'1': | ||
exit(false); | ||
// TODO | ||
'0': | ||
Error('Not yet implemented'); | ||
end; | ||
end; | ||
} |
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,46 @@ | ||
{ | ||
"id": "ff0caa38-65a2-49c5-a7e2-6a0475cfc60e", | ||
"name": "SharePoint Test Library", | ||
"publisher": "Microsoft", | ||
"version": "21.4.0.0", | ||
"brief": "Test libraries for the SharePoint module", | ||
"description": "Provides a set of AL functionality and Helper libraries to make use of SharePoint REST API", | ||
"privacyStatement": "https://go.microsoft.com/fwlink/?linkid=724009", | ||
"EULA": "https://go.microsoft.com/fwlink/?linkid=2009120", | ||
"help": "https://go.microsoft.com/fwlink/?linkid=2103698", | ||
"url": "https://go.microsoft.com/fwlink/?linkid=724011", | ||
"logo": "", | ||
"dependencies": [ | ||
{ | ||
"id": "199527d2-53dd-48e1-8732-8850d4f9e45b", | ||
"name": "WebDAV", | ||
"publisher": "Microsoft", | ||
"version": "21.4.0.0" | ||
}, | ||
{ | ||
"id": "ff0caa38-65a2-49c5-a7e2-6a0475cfc60e", | ||
"name": "SharePoint Test Library", | ||
"publisher": "Microsoft", | ||
"version": "21.4.0.0" | ||
} | ||
], | ||
"screenshots": [ | ||
|
||
], | ||
"features": [ | ||
|
||
], | ||
"platform": "21.0.0.0", | ||
"idRanges": [ | ||
{ | ||
"from": 135690, | ||
"to": 135699 | ||
} | ||
], | ||
"contextSensitiveHelpUrl": "https://go.microsoft.com/fwlink/?linkid=2206603", | ||
"resourceExposurePolicy": { | ||
"allowDebugging": true, | ||
"allowDownloadingSource": true, | ||
"includeSourceInSymbolFile": true | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Teeny thing, but Successful is with one l