Skip to content

Commit d2deeba

Browse files
committed
#7 Don't allow test to run as SYSDBA
1 parent 9c3c310 commit d2deeba

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin/PlsqlDeveloperUtPlsqlPlugin.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Runtime.InteropServices;
8+
using System.Threading.Tasks;
89
using System.Windows.Forms;
910

1011
namespace utPLSQL
@@ -206,7 +207,7 @@ public static void OnMenuClick(int index)
206207
{
207208
if (index == PluginMenuIndexAllTests)
208209
{
209-
if (connected())
210+
if (connected() && !Sydba())
210211
{
211212
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
212213
Windows.Add(testResultWindow);
@@ -215,7 +216,7 @@ public static void OnMenuClick(int index)
215216
}
216217
else if (index == PluginMenuIndexAllTestsWithCoverage)
217218
{
218-
if (connected())
219+
if (connected() && !Sydba())
219220
{
220221
var testResultWindow = new TestRunnerWindow(_plugin, username, password, database, connectAs);
221222
Windows.Add(testResultWindow);
@@ -224,7 +225,7 @@ public static void OnMenuClick(int index)
224225
}
225226
else if (index == PluginPopupIndex)
226227
{
227-
if (connected())
228+
if (connected() && !Sydba())
228229
{
229230
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
230231

@@ -236,7 +237,7 @@ public static void OnMenuClick(int index)
236237
}
237238
else if (index == PluginPopupIndexWithCoverage)
238239
{
239-
if (connected())
240+
if (connected() && !Sydba())
240241
{
241242
getPopupObject(out IntPtr type, out IntPtr owner, out IntPtr name, out IntPtr subType);
242243

@@ -262,6 +263,14 @@ public void OpenPackageBody(string owner, string name)
262263
var source = getObjectSource("PACKAGE BODY", owner, name);
263264
createWindow(3, Marshal.PtrToStringAnsi(source), false);
264265
}
266+
private static bool Sydba()
267+
{
268+
if (connectAs.ToLower().Equals("sysdba")) {
269+
MessageBox.Show("You shouldn't run utPLSQL as SYSDBA.\n\nTest will not run.", "Connected as SYSDBA", MessageBoxButtons.OK, MessageBoxIcon.Error);
270+
return true;
271+
}
272+
return true;
273+
}
265274

266275
private static void ConnectToDatabase()
267276
{

0 commit comments

Comments
 (0)