Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e948ad2
Remove IBM Bluemix as has been deprecated by IBM
ggallotti Jun 18, 2020
2810d1b
External Storage support
ggallotti Jun 1, 2021
bb1422d
Improvements
ggallotti Jun 10, 2021
fb0a546
Support for Path Style urls
ggallotti Jun 18, 2020
a7b076f
Add Minio Unit Tests
ggallotti Jun 10, 2021
5390fca
Remove launchSettings.json
ggallotti Jun 10, 2021
c1b4cfd
Remove Secrets
ggallotti Jun 11, 2021
8da1dc8
Every file is now private
ggallotti Jun 11, 2021
6b2bee0
Always add a GUID suffix to the name of uploaded image files.
claudiamurialdo Jun 4, 2021
671899b
Support for Private storage
claudiamurialdo Jun 7, 2021
1d2236e
Add Workflow for External Storage Unit Tests
ggallotti Jun 14, 2021
83d7f73
Workflow renamed
ggallotti Jun 14, 2021
226b578
Set Environment Variables
ggallotti Jun 14, 2021
c797599
Remove commented code
ggallotti Jun 16, 2021
a9f167a
Remove commented code
ggallotti Jun 16, 2021
e0c7674
Use TimeSpan instead of Minutes
ggallotti Jun 16, 2021
3c25ca9
Use TimeSpan instead of Minutes
ggallotti Jun 16, 2021
2707d4d
Do not require Folder Name
ggallotti Jun 16, 2021
1e91f04
Default expiration fix
ggallotti Jun 16, 2021
3039885
Add an environment to the testing workflow
jechague Jun 17, 2021
2b74060
Do not require S3 Endpoint.
ggallotti Jun 17, 2021
f58d157
Skip tests if Env Variables not set
ggallotti Jun 17, 2021
8aa4221
Workflow file
ggallotti Jun 18, 2021
05f22b9
Fix error: The project exceeded the rate limit for bucket operations
ggallotti Jun 18, 2021
7a835da
Do not run Tests in parallel, as Google fails by rate limiter.
ggallotti Jun 18, 2021
59c63e8
Spacing issue
ggallotti Jun 22, 2021
38bcbd7
Missing cherry pick
ggallotti Jun 22, 2021
8e5b8eb
Add WF to BETA
ggallotti Jun 22, 2021
6c33dc5
Add some random to Test because of Google Rate Limit exception
ggallotti Jun 22, 2021
0b5b6a2
Fix cherry-pick conflicts
ggallotti Jun 22, 2021
c2c75b9
Add test.txt resource
ggallotti Jun 22, 2021
2b71d83
Bump .NET FW Version for workflow
ggallotti Jun 22, 2021
3f9f755
Remove Workflow from beta branches
ggallotti Jun 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/External-Storage-Tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: External Storage Tests

on:
pull_request:
branches:
- 'master'
- 'release-*'
push:
branches:
- 'master'
- 'beta'
- 'release-*'

jobs:
build:
env:
GIT_REF: ${{ github.ref }}
GIT_SHA: ${{ github.sha }}
Configuration: Release
SolutionFile: dotnet\DotNetStandardClasses.sln

runs-on: windows-latest
environment: external-storage-tests

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install .NET Core 3.1
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'

- name: Install .NET Core 5.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'

- name: Install .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
include-prerelease: True

- uses: actions/setup-dotnet@v1
with:
source-url: https://nuget.pkg.github.com/genexuslabs/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Calculate environment variables
run: |
$IsPrerelease = !($Env:GIT_REF -match 'release-[0-9]+(?:\.[0-9]+)?$')
echo "IsPrerelease=$IsPrerelease" >> $env:GITHUB_ENV

$COMMIT_NUMBER = @($(git rev-list --count origin/master..), $(git rev-list --count HEAD))[$IsPrerelease]

echo "COMMIT_NUMBER=$COMMIT_NUMBER" >> $env:GITHUB_ENV

- name: Calculate package version
env:
PackageVersionString: ./.github/generatePackageVersion.ps1
run: |
$NuGetPackageVersion = & "$Env:PackageVersionString"

Write-Output "Packge version to be used: $NuGetPackageVersion"

echo "NuGetPackageVersion=$NuGetPackageVersion" >> $env:GITHUB_ENV

- name: Restore packages
run: dotnet restore $Env:SolutionFile

- name: Build
run: dotnet build $Env:SolutionFile --no-restore --configuration $Env:Configuration

- name: Test External Storage
run: |
$Env:AWSS3_TEST_ENABLED="true"
$Env:STORAGE_AWSS3_ACCESS_KEY="${{ secrets.AWSS3_ACCESS_KEY }}"
$Env:STORAGE_AWSS3_SECRET_KEY="${{ secrets.AWSS3_SECRET_KEY }}"
$Env:STORAGE_AWSS3_BUCKET_NAME="genexus-s3-test"
$Env:STORAGE_AWSS3_FOLDER_NAME="gxclasses"
$Env:STORAGE_AWSS3_REGION="us-east-1"
$Env:IBMCOS_TEST_ENABLED="true"
$Env:STORAGE_IBMCOS_ACCESS_KEY="${{ secrets.IBMCOS_ACCESS_KEY }}"
$Env:STORAGE_IBMCOS_SECRET_KEY="${{ secrets.IBMCOS_SECRET_KEY }}"
$Env:STORAGE_IBMCOS_BUCKET_NAME="gxclasses-unit-tests"
$Env:STORAGE_IBMCOS_FOLDER_NAME="tests"
$Env:STORAGE_IBMCOS_REGION="us-south"
$Env:AZUREBS_TEST_ENABLED="true"
$Env:STORAGE_AZUREBS_ACCESS_KEY="${{ secrets.AZUREBS_ACCESS_KEY }}"
$Env:STORAGE_AZUREBS_ACCOUNT_NAME="${{ secrets.AZUREBS_ACCOUNT_NAME }}"
$Env:STORAGE_AZUREBS_FOLDER_NAME="tests"
$Env:STORAGE_AZUREBS_PUBLIC_CONTAINER_NAME="contluispublic"
$Env:STORAGE_AZUREBS_PRIVATE_CONTAINER_NAME="contluisprivate"
$Env:GOOGLECS_TEST_ENABLED="true"
$Env:STORAGE_GOOGLECS_KEY='${{ secrets.GOOGLECS_KEY }}'
$Env:STORAGE_GOOGLECS_PROJECT_ID="gxjavacloudstorageunittests"
$Env:STORAGE_GOOGLECS_BUCKET_NAME="javaclasses-unittests"
$Env:STORAGE_GOOGLECS_FOLDER_NAME="gxclasses"
$Env:STORAGE_GOOGLECS_APPLICATION_NAME="gxjavacloudstorageunittests"

dotnet test $Env:SolutionFile --no-restore --no-build --configuration $Env:Configuration

7 changes: 0 additions & 7 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAmazonS3", "src\dotnetfra
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXAzureStorage", "src\dotnetframework\Providers\Storage\GXAzureStorage\GXAzureStorage.csproj", "{F6372249-AF37-4455-B572-5BDF8DE2ACC8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXBluemix", "src\dotnetframework\Providers\Storage\GXBluemix\GXBluemix.csproj", "{FCA5536D-542E-480E-92B0-316E0290553B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXGoogleCloud", "src\dotnetframework\Providers\Storage\GXGoogleCloud\GXGoogleCloud.csproj", "{E9072D95-D116-4D4B-B981-46146BCDE052}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GXOpenStack", "src\dotnetframework\Providers\Storage\GXOpenStack\GXOpenStack.csproj", "{64E958D8-CE7B-482D-B339-3B52E26CA4AC}"
Expand Down Expand Up @@ -249,10 +247,6 @@ Global
{F6372249-AF37-4455-B572-5BDF8DE2ACC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6372249-AF37-4455-B572-5BDF8DE2ACC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6372249-AF37-4455-B572-5BDF8DE2ACC8}.Release|Any CPU.Build.0 = Release|Any CPU
{FCA5536D-542E-480E-92B0-316E0290553B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FCA5536D-542E-480E-92B0-316E0290553B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FCA5536D-542E-480E-92B0-316E0290553B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FCA5536D-542E-480E-92B0-316E0290553B}.Release|Any CPU.Build.0 = Release|Any CPU
{E9072D95-D116-4D4B-B981-46146BCDE052}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9072D95-D116-4D4B-B981-46146BCDE052}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9072D95-D116-4D4B-B981-46146BCDE052}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -398,7 +392,6 @@ Global
{F82842DA-F15E-49C5-993E-4C269818FF1F} = {F900A4AD-7249-41B4-B918-CB9E8C73747C}
{3701565F-1A95-4592-B90D-291CCDE5505D} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{F6372249-AF37-4455-B572-5BDF8DE2ACC8} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{FCA5536D-542E-480E-92B0-316E0290553B} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{E9072D95-D116-4D4B-B981-46146BCDE052} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{64E958D8-CE7B-482D-B339-3B52E26CA4AC} = {F82842DA-F15E-49C5-993E-4C269818FF1F}
{A14C2C2C-ACE3-4712-A527-E4E5F02729FA} = {F900A4AD-7249-41B4-B918-CB9E8C73747C}
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/dotnetcore/GxClasses/GxClasses.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="..\..\dotnetframework\GxClasses\Services\Search\GXSearch.cs" Link="Services\Search\GXSearch.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Security\GxSecurityProvider.cs" Link="Security\GxSecurityProvider.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Services\Storage\GXServices.cs" Link="Services\Storage\GXServices.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Services\Storage\ExternalProviderBase.cs" Link="Services\Storage\ExternalProviderBase.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GxSession.cs" Link="Domain\GxSession.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\GXSilentTrn.cs" Link="Model\GXSilentTrn.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Services\Caching\GxSmartCacheProvider.cs" Link="Services\Caching\GxSmartCacheProvider.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public bool Connect(string profileName, GXProperties properties, ref GxStoragePr

private void preprocess(String name, GXProperties properties)
{
string className = null;
string className;

switch (name)
{
Expand All @@ -104,37 +104,27 @@ private void preprocess(String name, GXProperties properties)
className = "GeneXus.Storage.GXAmazonS3.ExternalProviderS3";
SetDefaultProperty(properties, "STORAGE_PROVIDER_REGION", "us-east-1");
SetDefaultProperty(properties, "STORAGE_ENDPOINT", "s3.amazonaws.com");
SetEncryptProperty(properties, "STORAGE_PROVIDER_ACCESSKEYID");
SetEncryptProperty(properties, "STORAGE_PROVIDER_SECRETACCESSKEY");
SetEncryptProperty(properties, "BUCKET_NAME");
SetEncryptedProperty(properties, "STORAGE_PROVIDER_ACCESSKEYID");
SetEncryptedProperty(properties, "STORAGE_PROVIDER_SECRETACCESSKEY");
SetEncryptedProperty(properties, "BUCKET_NAME");
break;

case "AZURESTORAGE":
className = "GeneXus.Storage.GXAzureStorage.AzureStorageExternalProvider";
SetEncryptProperty(properties, "PUBLIC_CONTAINER_NAME");
SetEncryptProperty(properties, "PRIVATE_CONTAINER_NAME");
SetEncryptProperty(properties, "ACCOUNT_NAME");
SetEncryptProperty(properties, "ACCESS_KEY");
SetEncryptedProperty(properties, "PUBLIC_CONTAINER_NAME");
SetEncryptedProperty(properties, "PRIVATE_CONTAINER_NAME");
SetEncryptedProperty(properties, "ACCOUNT_NAME");
SetEncryptedProperty(properties, "ACCESS_KEY");
break;

case "BLUEMIXSTORAGE":
className = "GeneXus.Storage.GXBluemix.ExternalProviderBluemix";
SetDefaultProperty(properties, "SERVER_URL", "https://identity.open.softlayer.com");
SetDefaultProperty(properties, "STORAGE_PROVIDER_REGION", "dallas");
SetEncryptProperty(properties, "PUBLIC_BUCKET_NAME");
SetEncryptProperty(properties, "PRIVATE_BUCKET_NAME");
SetEncryptProperty(properties, "STORAGE_PROVIDER_USER");
SetEncryptProperty(properties, "STORAGE_PROVIDER_PASSWORD");
break;


//case "BOX":
// className = "{class}";
// break;

case "GOOGLE":
className = "GeneXus.Storage.GXGoogleCloud.ExternalProviderGoogle";
SetEncryptProperty(properties, "KEY");
SetEncryptProperty(properties, "BUCKET_NAME");
SetEncryptedProperty(properties, "KEY");
SetEncryptedProperty(properties, "BUCKET_NAME");
break;

//case "IBMCOS":
Expand All @@ -146,9 +136,9 @@ private void preprocess(String name, GXProperties properties)

case "OPENSTACKSTORAGE":
className = "GeneXus.Storage.GXOpenStack.ExternalProviderOpenStack";
SetEncryptProperty(properties, "BUCKET_NAME");
SetEncryptProperty(properties, "STORAGE_PROVIDER_USER");
SetEncryptProperty(properties, "STORAGE_PROVIDER_PASSWORD");
SetEncryptedProperty(properties, "BUCKET_NAME");
SetEncryptedProperty(properties, "STORAGE_PROVIDER_USER");
SetEncryptedProperty(properties, "STORAGE_PROVIDER_PASSWORD");
break;

default:
Expand All @@ -171,7 +161,7 @@ private void SetDefaultProperty(GXProperties properties, String prop, String val
properties.Set(prop, value);
}

private void SetEncryptProperty(GXProperties properties, String prop)
private void SetEncryptedProperty(GXProperties properties, String prop)
{
String value = properties.Get(prop);
if (string.IsNullOrEmpty(value))
Expand Down
9 changes: 3 additions & 6 deletions dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,18 +679,15 @@ public static bool GetHttpRequestPostedFile(IGxContext gxContext, string varName
if (httpContext != null)
{
HttpPostedFile pf = httpContext.Request.GetFile(varName);
if (pf != null)
if (pf != null && pf.ContentLength > 0)
{
#pragma warning disable SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
FileInfo fi = new FileInfo(pf.FileName);
#pragma warning restore SCS0018 // Path traversal: injection possible in {1} argument passed to '{0}'
string tempDir = Preferences.getTMP_MEDIA_PATH();
string ext = fi.Extension;
string ext = Path.GetExtension(pf.FileName);
if (ext != null)
ext = ext.TrimStart('.');
string filePath = FileUtil.getTempFileName(tempDir);
GXLogging.Debug(log, "cgiGet(" + varName + "), fileName:" + filePath);
GxFile file = new GxFile(tempDir, filePath, GxFileType.PrivateAttribute);
GxFile file = new GxFile(tempDir, filePath, GxFileType.Private);
filePath = file.Create(pf.InputStream);
string fileGuid = GxUploadHelper.GetUploadFileGuid();
fileToken = GxUploadHelper.GetUploadFileId(fileGuid);
Expand Down
22 changes: 13 additions & 9 deletions dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1116,12 +1116,13 @@ public bool Upload(string filefullpath, string storageobjectfullname, GxFile upl
try
{
ValidProvider();
GxFileType acl = GxFileType.PublicRead;
if (String.IsNullOrEmpty(storageobjectfullname))
{
storageobjectfullname = Path.GetFileName(filefullpath);
}
string url = provider.Upload(filefullpath, storageobjectfullname, GxFileType.Public);
uploadedFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider);
string url = provider.Upload(filefullpath, storageobjectfullname, acl);
uploadedFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider, acl);
return true;
}
catch (Exception ex)
Expand All @@ -1139,8 +1140,9 @@ public bool UploadPrivate(string filefullpath, string storageobjectfullname, GxF
{
storageobjectfullname=Path.GetFileName(filefullpath);
}
string url = provider.Upload(filefullpath, storageobjectfullname, GxFileType.Private);
uploadedFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider);
GxFileType acl = GxFileType.Private;
string url = provider.Upload(filefullpath, storageobjectfullname, acl);
uploadedFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider, acl);
return true;
}
catch (Exception ex)
Expand All @@ -1160,7 +1162,7 @@ public bool Download(string storageobjectfullname, GxFile localFile, GXBaseColle
destFileName = localFile.GetAbsoluteName();
else
destFileName = Path.Combine(GxContext.StaticPhysicalPath(), localFile.Source);
provider.Download(storageobjectfullname, destFileName, GxFileType.Public);
provider.Download(storageobjectfullname, destFileName, GxFileType.PublicRead);
return true;
}
catch (Exception ex)
Expand Down Expand Up @@ -1197,15 +1199,16 @@ public bool Get(string storageobjectfullname, GxFile externalFile, GXBaseCollect
try
{
ValidProvider();
string url = provider.Get(storageobjectfullname, GxFileType.Public, 0);
GxFileType acl = GxFileType.PublicRead;
string url = provider.Get(storageobjectfullname, acl, 0);
if (String.IsNullOrEmpty(url))
{
GXUtil.ErrorToMessages("Get Error", "File doesn't exists", messages);
return false;
}
else
{
externalFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider);
externalFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider, acl);
return true;
}
}
Expand All @@ -1222,15 +1225,16 @@ public bool GetPrivate(string storageobjectfullname, GxFile externalFile, int ex
try
{
ValidProvider();
string url = provider.Get(storageobjectfullname, GxFileType.Private, expirationMinutes);
GxFileType acl = GxFileType.Private;
string url = provider.Get(storageobjectfullname, acl, expirationMinutes);
if (String.IsNullOrEmpty(url))
{
GXUtil.ErrorToMessages("Get Error", "File doesn't exists", messages);
return false;
}
else
{
externalFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider, GxFileType.Private);
externalFile.FileInfo = new GxExternalFileInfo(storageobjectfullname, url, provider, acl);
return true;
}
}
Expand Down
15 changes: 12 additions & 3 deletions dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
using System.Security.Cryptography;
using System.Collections.Concurrent;
using System.Drawing.Drawing2D;
using GeneXus.Storage;
using GeneXus.Services;

namespace GeneXus.Utils
{
Expand Down Expand Up @@ -3363,7 +3365,7 @@ public static string UriToPath(string uriString)
return uriString;
}
}
public static string getTempFileName(string baseDir, string name="", string extension="tmp", GxFileType fileType = GxFileType.Public)
public static string getTempFileName(string baseDir, string name="", string extension="tmp", GxFileType fileType = GxFileType.Private)
{
name = FixFileName(FileUtil.FileNamePrettify(name), string.Empty);
return tempFileName(baseDir, name, extension);
Expand Down Expand Up @@ -5256,15 +5258,22 @@ public static string ResolveUri(string uriString, IGxContext context = null)
public static string ResolveUri(string uriString, bool absUrl, IGxContext context = null)
{
if (String.IsNullOrEmpty(uriString))
return "";
return string.Empty;

string providerObjectName;
if (PathUtil.IsAbsoluteUrl(uriString) && StorageFactory.TryGetProviderObjectName(ServiceFactory.GetExternalProvider(), uriString, out providerObjectName))
{
return new GxFile(string.Empty, providerObjectName).GetURI();
}

if (schemeRegex.IsMatch(uriString))
{
string fileName = schemeRegex.Replace(uriString, "");
//Same way as getBlobFile, creates a GxFile in order to take into account external storage when enabled.
string basePath = Path.Combine(Path.Combine(Preferences.getBLOB_PATH(), MultimediaDirectory));
try
{
GxFile file = new GxFile(string.Empty, PathUtil.SafeCombine(basePath, fileName), GxFileType.PublicAttribute);
GxFile file = new GxFile(string.Empty, PathUtil.SafeCombine(basePath, fileName));
return PathToUrl(file.GetURI(), absUrl, context);
}
catch (ArgumentException ex)
Expand Down
Loading