From ebcf4f4fdbaaf9b373ceae52571fb41e5ff1973c Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 26 Aug 2018 23:03:51 +0200 Subject: [PATCH] Changed the dropbox code to use the Greenshot OAuth redirect, added a test for some of the ini values, this fails as there seems to be an issue. --- .../DropboxDestination.cs | 8 +-- .../Greenshot.PerformanceTests.csproj | 14 ++++++ .../packages.config | 4 ++ src/Greenshot.Tests/Greenshot.Tests.csproj | 14 ++++++ src/Greenshot.Tests/IniTests.cs | 50 +++++++++++++++++++ src/Greenshot.Tests/packages.config | 3 ++ 6 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/Greenshot.Tests/IniTests.cs diff --git a/src/Greenshot.Addon.Dropbox/DropboxDestination.cs b/src/Greenshot.Addon.Dropbox/DropboxDestination.cs index 9620084f7..f032e72b5 100644 --- a/src/Greenshot.Addon.Dropbox/DropboxDestination.cs +++ b/src/Greenshot.Addon.Dropbox/DropboxDestination.cs @@ -94,17 +94,19 @@ namespace Greenshot.Addon.Dropbox {"response_type", "code"}, {"client_id", "{ClientId}"}, {"redirect_uri", "{RedirectUrl}"}, + // TODO: Add version? {"state", "{State}"} }), TokenUrl = DropboxApiUri.AppendSegments("1", "oauth2", "token"), CloudServiceName = "Dropbox", ClientId = dropboxPluginConfiguration.ClientId, ClientSecret = dropboxPluginConfiguration.ClientSecret, - AuthorizeMode = AuthorizeModes.LocalhostServer, - RedirectUrl = "http://localhost:47336", + AuthorizeMode = AuthorizeModes.OutOfBoundAuto, + RedirectUrl = "https://getgreenshot.org/oauth/dropbox", Token = dropboxPluginConfiguration }; - var httpBehaviour = OAuth2HttpBehaviourFactory.Create(_oAuth2Settings); + + var httpBehaviour = OAuth2HttpBehaviourFactory.Create(_oAuth2Settings); _oAuthHttpBehaviour = httpBehaviour; // Use the default network settings diff --git a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj index 1169d4715..fcf37cfec 100644 --- a/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj +++ b/src/Greenshot.PerformanceTests/Greenshot.PerformanceTests.csproj @@ -52,6 +52,12 @@ ..\packages\Dapplo.CaliburnMicro.Translations.1.0.72\lib\net461\Dapplo.CaliburnMicro.Translations.dll + + ..\packages\Dapplo.HttpExtensions.0.8.43\lib\net46\Dapplo.HttpExtensions.dll + + + ..\packages\Dapplo.HttpExtensions.OAuth.0.8.43\lib\net46\Dapplo.HttpExtensions.OAuth.dll + ..\packages\Dapplo.Ini.0.5.28\lib\net45\Dapplo.Ini.dll @@ -70,6 +76,9 @@ ..\packages\Dapplo.Windows.0.5.109\lib\net461\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.Com.0.5.80\lib\net46\Dapplo.Windows.Com.dll + ..\packages\Dapplo.Windows.Common.0.5.109\lib\net461\Dapplo.Windows.Common.dll @@ -79,6 +88,9 @@ ..\packages\Dapplo.Windows.Dpi.0.5.109\lib\net461\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.EmbeddedBrowser.0.5.80\lib\net46\Dapplo.Windows.EmbeddedBrowser.dll + ..\packages\Dapplo.Windows.Gdi32.0.5.109\lib\net461\Dapplo.Windows.Gdi32.dll @@ -157,6 +169,7 @@ True + ..\packages\System.Reactive.4.1.0\lib\net46\System.Reactive.dll @@ -208,6 +221,7 @@ ..\packages\System.Security.Principal.Windows.4.5.0\lib\net461\System.Security.Principal.Windows.dll + ..\packages\System.Text.Encoding.CodePages.4.5.0\lib\net461\System.Text.Encoding.CodePages.dll diff --git a/src/Greenshot.PerformanceTests/packages.config b/src/Greenshot.PerformanceTests/packages.config index 7e227fe57..66293ebbc 100644 --- a/src/Greenshot.PerformanceTests/packages.config +++ b/src/Greenshot.PerformanceTests/packages.config @@ -12,15 +12,19 @@ + + + + diff --git a/src/Greenshot.Tests/Greenshot.Tests.csproj b/src/Greenshot.Tests/Greenshot.Tests.csproj index b4f4b41ff..d6e6864a5 100644 --- a/src/Greenshot.Tests/Greenshot.Tests.csproj +++ b/src/Greenshot.Tests/Greenshot.Tests.csproj @@ -87,6 +87,9 @@ ..\packages\Dapplo.HttpExtensions.0.8.43\lib\net46\Dapplo.HttpExtensions.dll + + ..\packages\Dapplo.HttpExtensions.OAuth.0.8.43\lib\net46\Dapplo.HttpExtensions.OAuth.dll + ..\packages\Dapplo.Ini.0.5.28\lib\net45\Dapplo.Ini.dll @@ -105,6 +108,9 @@ ..\packages\Dapplo.Windows.0.5.109\lib\net461\Dapplo.Windows.dll + + ..\packages\Dapplo.Windows.Com.0.5.109\lib\net461\Dapplo.Windows.Com.dll + ..\packages\Dapplo.Windows.Common.0.5.109\lib\net461\Dapplo.Windows.Common.dll @@ -114,6 +120,9 @@ ..\packages\Dapplo.Windows.Dpi.0.5.109\lib\net461\Dapplo.Windows.Dpi.dll + + ..\packages\Dapplo.Windows.EmbeddedBrowser.0.5.109\lib\net461\Dapplo.Windows.EmbeddedBrowser.dll + ..\packages\Dapplo.Windows.Gdi32.0.5.109\lib\net461\Dapplo.Windows.Gdi32.dll @@ -310,6 +319,7 @@ + @@ -321,6 +331,10 @@ + + {ad7cffe2-40e7-46cf-a172-d48cf7ae9a12} + Greenshot.Addon.Dropbox + {5b924697-4dcd-4f98-85f1-105cb84b7341} Greenshot.Addons diff --git a/src/Greenshot.Tests/IniTests.cs b/src/Greenshot.Tests/IniTests.cs new file mode 100644 index 000000000..4baa04ddb --- /dev/null +++ b/src/Greenshot.Tests/IniTests.cs @@ -0,0 +1,50 @@ +#region Greenshot GNU General Public License + +// Greenshot - a free and open source screenshot tool +// Copyright (C) 2007-2018 Thomas Braun, Jens Klingen, Robin Krom +// +// For more information see: http://getgreenshot.org/ +// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 1 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#endregion + +using System.Threading.Tasks; +using Dapplo.Ini; +using Dapplo.Ini.Converters; +using Greenshot.Addon.Dropbox; +using Xunit; + +namespace Greenshot.Tests +{ + public class IniTests + { + [Fact] + public async Task ConstIniTest() + { + // TODO: Set via build + StringEncryptionTypeConverter.RgbIv = "dlgjowejgogkklwj"; + StringEncryptionTypeConverter.RgbKey = "lsjvkwhvwujkagfauguwcsjgu2wueuff"; + + using (var iniConfig = new IniConfig("greenshot", "greenshot")) + { + await iniConfig.LoadIfNeededAsync(); + var dropboxConfiguration = iniConfig.Get(); + // TODO: Fix this!! + Assert.NotEqual("@credentials_dropbox_consumer_key@", dropboxConfiguration.ClientId); + } + } + } +} diff --git a/src/Greenshot.Tests/packages.config b/src/Greenshot.Tests/packages.config index 996a8882c..b94e79ab8 100644 --- a/src/Greenshot.Tests/packages.config +++ b/src/Greenshot.Tests/packages.config @@ -15,15 +15,18 @@ + + +