From 560557a0f682faecca9da4057f216c9162309c35 Mon Sep 17 00:00:00 2001 From: anurag2787 Date: Thu, 2 Oct 2025 13:10:28 +0530 Subject: [PATCH 1/2] Added Input Validation --- .../io/github/lambdatest/gradle/LambdaTestTask.java | 12 ++++++++++++ .../github/lambdatest/gradle/LambdaUploaderTask.java | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java b/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java index 44af815..81bab2f 100644 --- a/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java +++ b/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java @@ -127,18 +127,30 @@ public void runLambdaTest() { // setter methods for the properties public void setUsername(String username) { + if (username == null || username.trim().isEmpty()) { + throw new IllegalArgumentException("Username cannot be null or empty"); + } this.username = username; } public void setAccessKey(String accessKey) { + if (accessKey == null || accessKey.trim().isEmpty()) { + throw new IllegalArgumentException("Access key cannot be null or empty"); + } this.accessKey = accessKey; } public void setAppFilePath(String appFilePath) { + if (appFilePath == null || appFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("App file path cannot be null or empty"); + } this.appFilePath = appFilePath; } public void setTestSuiteFilePath(String testSuiteFilePath) { + if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("Test suite file path cannot be null or empty"); + } this.testSuiteFilePath = testSuiteFilePath; } diff --git a/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java b/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java index dc65649..d732566 100644 --- a/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java +++ b/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java @@ -66,18 +66,30 @@ public void uploadApkToLambdaTest() { // Setter functions for the task public void setUsername(String username) { + if (username == null || username.trim().isEmpty()) { + throw new IllegalArgumentException("Username cannot be null or empty"); + } this.username = username; } public void setAccessKey(String accessKey) { + if (accessKey == null || accessKey.trim().isEmpty()) { + throw new IllegalArgumentException("Access key cannot be null or empty"); + } this.accessKey = accessKey; } public void setAppFilePath(String appFilePath) { + if (appFilePath == null || appFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("App file path cannot be null or empty"); + } this.appFilePath = appFilePath; } public void setTestSuiteFilePath(String testSuiteFilePath) { + if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("Test suite file path cannot be null or empty"); + } this.testSuiteFilePath = testSuiteFilePath; } } From 41fcbd42e94fe093439e0e932b73f6eca94b519f Mon Sep 17 00:00:00 2001 From: anurag2787 Date: Thu, 30 Oct 2025 08:34:25 +0530 Subject: [PATCH 2/2] Updated checks --- .../java/io/github/lambdatest/gradle/LambdaTestTask.java | 8 ++++---- .../io/github/lambdatest/gradle/LambdaUploaderTask.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java b/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java index 6be5e27..897bd85 100644 --- a/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java +++ b/src/main/java/io/github/lambdatest/gradle/LambdaTestTask.java @@ -171,15 +171,15 @@ public void setAccessKey(String accessKey) { } public void setAppFilePath(String appFilePath) { - if (appFilePath == null || appFilePath.trim().isEmpty()) { - throw new IllegalArgumentException("App file path cannot be null or empty"); + if (appFilePath != null && appFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("App file path cannot be empty"); } this.appFilePath = appFilePath; } public void setTestSuiteFilePath(String testSuiteFilePath) { - if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) { - throw new IllegalArgumentException("Test suite file path cannot be null or empty"); + if (testSuiteFilePath != null && testSuiteFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("Test suite file path cannot be empty"); } this.testSuiteFilePath = testSuiteFilePath; } diff --git a/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java b/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java index 0f30e32..3bb02f0 100644 --- a/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java +++ b/src/main/java/io/github/lambdatest/gradle/LambdaUploaderTask.java @@ -118,15 +118,15 @@ public void setAccessKey(String accessKey) { } public void setAppFilePath(String appFilePath) { - if (appFilePath == null || appFilePath.trim().isEmpty()) { - throw new IllegalArgumentException("App file path cannot be null or empty"); + if (appFilePath != null && appFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("App file path cannot be empty"); } this.appFilePath = appFilePath; } public void setTestSuiteFilePath(String testSuiteFilePath) { - if (testSuiteFilePath == null || testSuiteFilePath.trim().isEmpty()) { - throw new IllegalArgumentException("Test suite file path cannot be null or empty"); + if (testSuiteFilePath != null && testSuiteFilePath.trim().isEmpty()) { + throw new IllegalArgumentException("Test suite file path cannot be empty"); } this.testSuiteFilePath = testSuiteFilePath; }