Skip to content

Commit ea86991

Browse files
add: startup parameter -TEST_SSL
Must check if the actual GUI program SSL is working
1 parent 59bcc7b commit ea86991

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

source/code/main.pas

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ TFormTrackerModify = class(TForm)
188188
procedure UpdateTrackerInsideFileList;
189189
procedure UpdateTorrentTrackerList;
190190
procedure ShowTrackerInsideFileList;
191+
function TestConnectionSSL: Boolean;
191192

192193
procedure CheckedOnOffAllTrackers(Value: boolean);
193194
function CopyUserInputNewTrackersToList(Temporary_SkipAnnounceCheck: boolean =
@@ -203,7 +204,7 @@ TFormTrackerModify = class(TForm)
203204

204205
implementation
205206

206-
uses LCLIntf, lazutf8, LazFileUtils, trackerlist_online;
207+
uses fphttpclient, LCLIntf, lazutf8, LazFileUtils, trackerlist_online;
207208

208209
const
209210
RECOMENDED_TRACKERS: array[0..2] of UTF8String =
@@ -225,6 +226,14 @@ implementation
225226

226227
procedure TFormTrackerModify.FormCreate(Sender: TObject);
227228
begin
229+
//Test the working for SSL connection
230+
if TestConnectionSSL then
231+
begin
232+
// shutdown the GUI program
233+
Application.terminate;
234+
Exit;
235+
end;
236+
228237
//Create controler for StringGridTorrentData
229238
FControlerGridTorrentData := TControlerGridTorrentData.Create(StringGridTorrentData);
230239

@@ -1795,4 +1804,23 @@ procedure TFormTrackerModify.ShowHourGlassCursor(HourGlass: boolean);
17951804

17961805
end;
17971806

1807+
function TFormTrackerModify.TestConnectionSSL: Boolean;
1808+
begin
1809+
Result := ParamCount = 1;
1810+
if Result then
1811+
begin
1812+
// Check for the correct parameter.
1813+
Result := UTF8Trim(ParamStr(1)) = '-TEST_SSL';
1814+
if Result then
1815+
begin
1816+
// Check if there is SLL connection
1817+
try
1818+
TFPCustomHTTPClient.SimpleGet('https://raw.githubusercontent.com/gerryferdinandus/bittorrent-tracker-editor/master/.travis.yml');
1819+
except
1820+
//No SLL or no internet connection.
1821+
System.ExitCode := 1;
1822+
end;
1823+
end;
1824+
end;
1825+
end;
17981826
end.

source/project/tracker_editor/trackereditor.lpi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
</CodeGeneration>
175175
<Linking>
176176
<Debugging>
177+
<DebugInfoType Value="dsDwarf3"/>
177178
<StripSymbols Value="True"/>
178179
</Debugging>
179180
<LinkSmart Value="True"/>

source/project/unit_test/tracker_editor_test.lpi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
</SearchPaths>
149149
<Linking>
150150
<Debugging>
151+
<DebugInfoType Value="dsDwarf3"/>
151152
<UseHeaptrc Value="True"/>
152153
</Debugging>
153154
</Linking>

source/test/test_start_up_parameter.pas

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ TTestStartUpParameter = class(TTestCase)
7979
procedure SetUp; override;
8080
procedure TearDown; override;
8181
published
82+
procedure Test_Parameter_TEST_SSL;
8283
procedure Test_Tracker_UserInput_All_Different_URL;
8384
procedure Test_Tracker_UserInput_All_Different_URL_And_SAC;
8485
procedure Test_Create_Empty_Torrent_And_Then_Filled_It_All_List_Order_Mode;
@@ -148,6 +149,15 @@ procedure TTestStartUpParameter.Test_Paramater_U7;
148149
Test_Paramater_Ux(tloRandomize);
149150
end;
150151

152+
procedure TTestStartUpParameter.Test_Parameter_TEST_SSL;
153+
begin
154+
// Check if SSL connection is working.
155+
FCommandLine := '-TEST_SSL';
156+
CallExecutableFile;
157+
// Exit code should be zero
158+
CheckEquals(0, FExitCode);
159+
end;
160+
151161
//procedure TTestStartUpParameter.TestParameter(TrackerListOrder: TTrackerListOrder);
152162
procedure TTestStartUpParameter.TestParameter(const StartupParameter: TStartupParameter);
153163
begin

0 commit comments

Comments
 (0)