Skip to content

Improve password variable handling and reset logic#4470

Merged
ravirk91 merged 3 commits into
masterfrom
Feature/48481_not-able-set-password-type-variable_EEBT
Mar 20, 2026
Merged

Improve password variable handling and reset logic#4470
ravirk91 merged 3 commits into
masterfrom
Feature/48481_not-able-set-password-type-variable_EEBT

Conversation

@tanushahande2003

@tanushahande2003 tanushahande2003 commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

VariablePasswordString now tracks initial value for proper reset. Password setter only sets initial value once. SetInitialValue stores encrypted value as initial and current. ActSetVariableValue supports updating password variables. Unit test updated to verify encryption/decryption. Password variables now selectable in UI.

Description

Type of Change

  • Bug fix - [ ] New feature - [ ] Breaking change - [ ] Plugin update

Checklist

  • PR description clearly describes the changes
  • Target branch is correct (master for features, Releases/* for fixes)
  • Latest code from target branch merged
  • No commented/junk code included
  • No new build warnings or errors
  • All existing unit tests pass
  • New unit tests added for new functionality
  • Cross-platform compatibility verified (Windows/Linux/macOS)
  • CI/CD pipeline passes
  • Code follows project conventions (Act{Platform}{Type}, {Platform}Driver)
  • Repository objects use [IsSerializedForLocalRepository] where needed
  • Error handling uses Reporter.ToLog() pattern
  • Documentation updated for user-facing changes
  • Self-review completed and code review comments addressed

Summary by CodeRabbit

  • Bug Fixes

    • Password-string variables now appear in variable selection dropdowns.
    • Setting password-string variables via the Set Variable Value action persists the value securely (encrypted) and restores correctly on reset.
  • Tests

    • Added unit tests to verify encrypted storage and correct decryption of password-string variables at business-flow and global scopes.

VariablePasswordString now tracks initial value for proper reset.
Password setter only sets initial value once. SetInitialValue
stores encrypted value as initial and current. ActSetVariableValue
supports updating password variables. Unit test updated to verify
encryption/decryption. Password variables now selectable in UI.
@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

UI filtering for password variables was relaxed, VariablePasswordString gained persistent initial-value handling and reset behavior, ActSetVariableValue now sets password variables via Var.SetValue, and unit tests were added/updated to validate encrypted storage and correct decryption.

Changes

Cohort / File(s) Summary
Password Variable Core Logic
Ginger/GingerCoreCommon/VariablesLib/VariablePasswordString.cs
Added private mInitialPassword; initialize it on first Password set; ResetValue() restores from mInitialPassword when present; SetInitialValue() stores value in both mInitialPassword and Password.
Action Logic
Ginger/GingerCoreNET/ActionsLib/General/ActSetVariableValue.cs
Handle VariablePasswordString when option is SetValue by calling Var.SetValue(calculatedValue) so password variables are set correctly.
UI Filtering
Ginger/Ginger/Actions/ActionEditPages/ActSetVariableValuePage.xaml.cs
Changed combo-box population filter to stop excluding VariablePasswordString (only VariableDynamic remains excluded), so password vars appear in the VariableName list.
Unit Tests
Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs
Updated existing password-string set-value test to assert encrypted storage and correct decryption; added tests for BusinessFlow-level and Global-level password variable set operations.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UI (ActSetVariableValuePage)
    participant Action as ActSetVariableValue
    participant Var as VariablePasswordString
    participant Enc as EncryptionHandler
    rect rgba(200,230,255,0.5)
    UI->>Action: User triggers SetValue for selected VariablePasswordString
    Action->>Var: call SetValue(calculatedValue)
    Var->>Enc: encrypt(calculatedValue) (internally)
    Enc-->>Var: encryptedValue
    Var-->>Action: confirm saved (Value updated, mInitialPassword set if needed)
    Action-->>UI: success / refresh UI
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ravirk91
  • Maheshkale447

Poem

🐰 I hopped through code with nimble paws,

Kept the secret safe behind its clause,
Initial tucked, then set with care,
From UI to action, encrypted there,
A quiet rabbit cheers — secure and fair.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description provides a concise summary of key changes but lacks details on file modifications, impact analysis, and only partially completes the provided template. Expand the description to specify which files were modified, explain the technical rationale for changes, and mark affected checklist items (especially testing and cross-platform verification status).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main changes: improving password variable handling and reset logic across multiple files, which aligns with the actual code modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Feature/48481_not-able-set-password-type-variable_EEBT
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Ginger/GingerCoreNET/ActionsLib/General/ActSetVariableValue.cs`:
- Around line 203-206: Update the VariablePasswordString branch to check the
boolean returned by Var.SetValue(calculatedValue) like the VariableSelectionList
branch does: call Var.SetValue and if it returns false, set the action error
(mError) with a clear message including the variable name (Var.Name) and return
false; otherwise continue as before. This keeps handling consistent and
defensive in case VariablePasswordString.SetValue changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c92de918-7dec-454b-a131-7252d415a773

📥 Commits

Reviewing files that changed from the base of the PR and between b29bce8 and f37114a.

📒 Files selected for processing (4)
  • Ginger/Ginger/Actions/ActionEditPages/ActSetVariableValuePage.xaml.cs
  • Ginger/GingerCoreCommon/VariablesLib/VariablePasswordString.cs
  • Ginger/GingerCoreNET/ActionsLib/General/ActSetVariableValue.cs
  • Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs

Comment on lines +203 to +206
else if (Var.GetType() == typeof(VariablePasswordString))
{
Var.SetValue(calculatedValue);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider checking the return value of SetValue for consistency.

Other branches like VariableSelectionList (line 130-135) check the result and set an error message on failure. While VariablePasswordString.SetValue currently always returns true (since SupportSetValue is hardcoded to true), checking the return value maintains consistency and provides defensive handling if the implementation changes.

Suggested improvement
 else if (Var.GetType() == typeof(VariablePasswordString))
 {
-    Var.SetValue(calculatedValue);
+    if (!Var.SetValue(calculatedValue))
+    {
+        Error = "Failed to set password variable '" + Var.Name + "'.";
+        return;
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
else if (Var.GetType() == typeof(VariablePasswordString))
{
Var.SetValue(calculatedValue);
}
else if (Var.GetType() == typeof(VariablePasswordString))
{
if (!Var.SetValue(calculatedValue))
{
Error = "Failed to set password variable '" + Var.Name + "'.";
return;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Ginger/GingerCoreNET/ActionsLib/General/ActSetVariableValue.cs` around lines
203 - 206, Update the VariablePasswordString branch to check the boolean
returned by Var.SetValue(calculatedValue) like the VariableSelectionList branch
does: call Var.SetValue and if it returns false, set the action error (mError)
with a clear message including the variable name (Var.Name) and return false;
otherwise continue as before. This keeps handling consistent and defensive in
case VariablePasswordString.SetValue changes.

tanushah added 2 commits March 20, 2026 12:05
Updated activity-level test for Password String Set Value support and added new tests for Business Flow and Global levels. Tests verify encrypted storage and correct value resolution at all supported scopes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs`:
- Around line 234-238: The test currently only checks that v1.Value differs from
initialValue and that DecryptwithKey(v1.Value) equals newValue; add an assertion
that v1.Value is not equal to newValue to ensure the stored value is not
plaintext (i.e., Assert.AreNotEqual(newValue, v1.Value)), keeping the existing
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value)) to verify
proper decryption; reference v1.Value, initialValue, newValue and
EncryptionHandler.DecryptwithKey when making this change.
- Around line 290-314: Save the current BusinessFlow.SolutionVariables before
setting it (capture its original value), and in the existing finally block
restore it after removing v1 so the test does not leave global state changed;
locate the assignment to BusinessFlow.SolutionVariables and add a local variable
to hold the original, then assign BusinessFlow.SolutionVariables back to that
original in the finally block alongside solution.Variables.Remove(v1).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 998fb109-df12-445d-ab94-c48e47e94bc8

📥 Commits

Reviewing files that changed from the base of the PR and between f37114a and 4e2862c.

📒 Files selected for processing (1)
  • Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs

Comment on lines +234 to +238
// Set Variable Action did not support Password String variables earlier (variable not listed / value not set at runtime).
// Support was added: Set Value encrypts and stores the new password. The test was updated accordingly—
// we assert the stored value is no longer the plain initial value, then decrypt and compare to the configured new value.
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Strengthen encryption assertion by also checking against newValue.

The current assertion Assert.AreNotEqual(initialValue, v1.Value) only confirms the value changed from the initial value. To truly verify the value is stored encrypted (not plaintext), also assert that the stored value differs from newValue:

 Assert.AreNotEqual(initialValue, v1.Value);
+Assert.AreNotEqual(newValue, v1.Value);
 Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));

This ensures the test fails if encryption is accidentally bypassed and plaintext is stored.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Set Variable Action did not support Password String variables earlier (variable not listed / value not set at runtime).
// Support was added: Set Value encrypts and stores the new password. The test was updated accordingly—
// we assert the stored value is no longer the plain initial value, then decrypt and compare to the configured new value.
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));
// Set Variable Action did not support Password String variables earlier (variable not listed / value not set at runtime).
// Support was added: Set Value encrypts and stores the new password. The test was updated accordingly—
// we assert the stored value is no longer the plain initial value, then decrypt and compare to the configured new value.
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreNotEqual(newValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs` around lines
234 - 238, The test currently only checks that v1.Value differs from
initialValue and that DecryptwithKey(v1.Value) equals newValue; add an assertion
that v1.Value is not equal to newValue to ensure the stored value is not
plaintext (i.e., Assert.AreNotEqual(newValue, v1.Value)), keeping the existing
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value)) to verify
proper decryption; reference v1.Value, initialValue, newValue and
EncryptionHandler.DecryptwithKey when making this change.

Comment on lines +290 to +314
BusinessFlow.SolutionVariables = WorkSpace.Instance.Solution.Variables;

VariablePasswordString v1 = new VariablePasswordString() { Name = variableName, Password = initialValue };
solution.Variables.Add(v1);

Activity activity1 = new Activity() { Active = true };
mBF.Activities.Add(activity1);

ActSetVariableValue actSetVariableValue = new ActSetVariableValue() { VariableName = variableName, SetVariableValueOption = VariableBase.eSetValueOptions.SetValue, Value = newValue, Active = true };
activity1.Acts.Add(actSetVariableValue);

try
{
mGR.Executor.RunRunner();

Assert.AreEqual(eRunStatus.Passed, mBF.RunStatus);
Assert.AreEqual(eRunStatus.Passed, activity1.Status);
// Password variables store the runtime value encrypted (VariablePasswordString.SetValue).
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));
}
finally
{
solution.Variables.Remove(v1);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Consider restoring BusinessFlow.SolutionVariables in the finally block.

Line 290 sets the static property BusinessFlow.SolutionVariables, but this is not restored after the test. If other tests depend on this property having a different (or null) value, test isolation may be compromised.

🛡️ Proposed fix to preserve test isolation
+            var originalSolutionVariables = BusinessFlow.SolutionVariables;
             BusinessFlow.SolutionVariables = WorkSpace.Instance.Solution.Variables;

             VariablePasswordString v1 = new VariablePasswordString() { Name = variableName, Password = initialValue };
             solution.Variables.Add(v1);
             ...
             finally
             {
                 solution.Variables.Remove(v1);
+                BusinessFlow.SolutionVariables = originalSolutionVariables;
             }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
BusinessFlow.SolutionVariables = WorkSpace.Instance.Solution.Variables;
VariablePasswordString v1 = new VariablePasswordString() { Name = variableName, Password = initialValue };
solution.Variables.Add(v1);
Activity activity1 = new Activity() { Active = true };
mBF.Activities.Add(activity1);
ActSetVariableValue actSetVariableValue = new ActSetVariableValue() { VariableName = variableName, SetVariableValueOption = VariableBase.eSetValueOptions.SetValue, Value = newValue, Active = true };
activity1.Acts.Add(actSetVariableValue);
try
{
mGR.Executor.RunRunner();
Assert.AreEqual(eRunStatus.Passed, mBF.RunStatus);
Assert.AreEqual(eRunStatus.Passed, activity1.Status);
// Password variables store the runtime value encrypted (VariablePasswordString.SetValue).
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));
}
finally
{
solution.Variables.Remove(v1);
}
var originalSolutionVariables = BusinessFlow.SolutionVariables;
BusinessFlow.SolutionVariables = WorkSpace.Instance.Solution.Variables;
VariablePasswordString v1 = new VariablePasswordString() { Name = variableName, Password = initialValue };
solution.Variables.Add(v1);
Activity activity1 = new Activity() { Active = true };
mBF.Activities.Add(activity1);
ActSetVariableValue actSetVariableValue = new ActSetVariableValue() { VariableName = variableName, SetVariableValueOption = VariableBase.eSetValueOptions.SetValue, Value = newValue, Active = true };
activity1.Acts.Add(actSetVariableValue);
try
{
mGR.Executor.RunRunner();
Assert.AreEqual(eRunStatus.Passed, mBF.RunStatus);
Assert.AreEqual(eRunStatus.Passed, activity1.Status);
// Password variables store the runtime value encrypted (VariablePasswordString.SetValue).
Assert.AreNotEqual(initialValue, v1.Value);
Assert.AreEqual(newValue, EncryptionHandler.DecryptwithKey(v1.Value));
}
finally
{
solution.Variables.Remove(v1);
BusinessFlow.SolutionVariables = originalSolutionVariables;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Ginger/GingerCoreNETUnitTest/NonUITests/GingerVariableTests.cs` around lines
290 - 314, Save the current BusinessFlow.SolutionVariables before setting it
(capture its original value), and in the existing finally block restore it after
removing v1 so the test does not leave global state changed; locate the
assignment to BusinessFlow.SolutionVariables and add a local variable to hold
the original, then assign BusinessFlow.SolutionVariables back to that original
in the finally block alongside solution.Variables.Remove(v1).

@ravirk91
ravirk91 merged commit 4921559 into master Mar 20, 2026
19 of 20 checks passed
@ravirk91
ravirk91 deleted the Feature/48481_not-able-set-password-type-variable_EEBT branch March 20, 2026 09:39
@coderabbitai coderabbitai Bot mentioned this pull request Mar 31, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants