Files
QSfera/scripts/verify-sharing-controls-coverage.ps1
2026-06-12 22:26:21 +03:00

89 lines
4.8 KiB
PowerShell

param(
[string]$RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "..")).Path
)
$ErrorActionPreference = "Stop"
function Fail($Message) {
Write-Error $Message
exit 1
}
function Assert-FileContains($Name, $RelativePath, $Pattern) {
$path = Join-Path $RepoRoot $RelativePath
if (-not (Test-Path -LiteralPath $path)) {
Fail "$Name source file is missing: $RelativePath"
}
$content = Get-Content -LiteralPath $path -Raw
if ($content -notmatch $Pattern) {
Fail "$Name was not found in $RelativePath. Pattern: $Pattern"
}
Write-Host "OK: $Name"
}
Write-Host "Checking QSfera sharing-controls coverage..."
Assert-FileContains "Android public-link dialog exposes password control" `
"Android/qsferaApp/src/main/java/eu/qsfera/android/presentation/sharing/shares/PublicShareDialogFragment.kt" `
"shareViaLinkPasswordSwitch"
Assert-FileContains "Android public-link dialog exposes expiration control" `
"Android/qsferaApp/src/main/java/eu/qsfera/android/presentation/sharing/shares/PublicShareDialogFragment.kt" `
"shareViaLinkExpirationSwitch"
Assert-FileContains "Android public-link dialog exposes upload-only mode" `
"Android/qsferaApp/src/main/java/eu/qsfera/android/presentation/sharing/shares/PublicShareDialogFragment.kt" `
"shareViaLinkEditPermissionUploadFiles"
Assert-FileContains "Android public-link rows show safety status" `
"Android/qsferaApp/src/main/java/eu/qsfera/android/presentation/sharing/shares/SharePublicLinkListAdapter.kt" `
"PublicShareStatusFormatter\.statusFor"
Assert-FileContains "Android public-link dialog protects server-managed custom links" `
"Android/qsferaApp/src/main/java/eu/qsfera/android/presentation/sharing/shares/PublicShareDialogFragment.kt" `
"isServerManagedPublicLink"
Assert-FileContains "Android public-link dialog explains managed access" `
"Android/qsferaApp/src/main/res/layout/share_public_dialog.xml" `
"shareViaLinkManagedAccessMessage"
Assert-FileContains "Graph API declares internal link type" `
"Server/vendor/github.com/opencloud-eu/libre-graph-api-go/model_sharing_link_type.go" `
"INTERNAL SharingLinkType = `"internal`""
Assert-FileContains "Graph API declares secure-view link type" `
"Server/vendor/github.com/opencloud-eu/libre-graph-api-go/model_sharing_link_type.go" `
"BLOCKS_DOWNLOAD SharingLinkType = `"blocksDownload`""
Assert-FileContains "Graph API declares file-drop link type" `
"Server/vendor/github.com/opencloud-eu/libre-graph-api-go/model_sharing_link_type.go" `
"CREATE_ONLY SharingLinkType = `"createOnly`""
Assert-FileContains "Server maps internal link to no public-share permissions" `
"Server/services/graph/pkg/linktype/linktype.go" `
"func NewInternalLinkPermissionSet\(\) \*LinkType[\s\S]*ResourcePermissions\{\}"
Assert-FileContains "Server rejects passwords on internal links" `
"Server/services/graph/pkg/service/v0/api_driveitem_permissions_links.go" `
"password is redundant for the internal link"
Assert-FileContains "Server stores link expiration during creation" `
"Server/services/graph/pkg/service/v0/api_driveitem_permissions_links.go" `
"GetExpirationDateTimeOk"
Assert-FileContains "Acceptance tests create link shares with password and expiration" `
"Server/tests/acceptance/features/apiSharingNgLinkSharePermission/createLinkShare.feature" `
"expirationDateTime[\s\S]*hasPassword"
Assert-FileContains "Acceptance tests update link-share expiration" `
"Server/tests/acceptance/features/apiSharingNgLinkSharePermission/updateLinkShare.feature" `
"update expiration date of a file's link share"
Assert-FileContains "Acceptance tests update link-share password and reject old password" `
"Server/tests/acceptance/features/apiSharingNgLinkSharePermission/updateLinkShare.feature" `
"public download of file[\s\S]*should fail with HTTP status code `"401`""
Assert-FileContains "Acceptance tests update public links to internal links" `
"Server/tests/acceptance/features/apiSharingNgLinkSharePermission/updateLinkShare.feature" `
"permissionsRole \| internal"
Assert-FileContains "Acceptance tests include secure viewer no-download behavior" `
"Server/tests/acceptance/features/apiSharingNg1/enableDisablePermissionsRole.feature" `
"Secure Viewer[\s\S]*should not be able to download"
Assert-FileContains "Acceptance tests enforce space-manager sharing rights" `
"Server/tests/acceptance/features/apiSpacesShares/shareSpaces.feature" `
"manager role can share[\s\S]*editor or viewer role cannot share"
Assert-FileContains "Acceptance tests enforce project-space public-link sharing rights" `
"Server/tests/acceptance/features/apiSpacesShares/shareSubItemOfSpaceViaPublicLink.feature" `
"space manager role can share[\s\S]*without space manager role cannot share"
Write-Host "QSfera sharing-controls coverage check passed."