|
| 1 | +component extends = "org.lucee.cfml.test.LuceeTestCase" { |
| 2 | + |
| 3 | + function run( testResults, testBox ){ |
| 4 | + describe( "Testcase for LDEV-6450 - Password cache issue after updateMapping", function(){ |
| 5 | + |
| 6 | + it( "Multiple updateMapping calls should work after setPassword", function() { |
| 7 | + var testPassword = "testpass_6450_" & randRange(10000,99999); |
| 8 | + var testVirtual1 = "/test_6450_mapping1_" & randRange(10000,99999); |
| 9 | + var testVirtual2 = "/test_6450_mapping2_" & randRange(10000,99999); |
| 10 | + var testPhysical = getTempDirectory() & "lucee_test_6450/"; |
| 11 | + |
| 12 | + // Ensure test directory exists |
| 13 | + if (!directoryExists(testPhysical)) { |
| 14 | + directoryCreate(testPhysical); |
| 15 | + } |
| 16 | + |
| 17 | + try { |
| 18 | + // Step 1: Set server admin password |
| 19 | + admin |
| 20 | + action="updatePassword" |
| 21 | + type="server" |
| 22 | + oldPassword="admin" |
| 23 | + newPassword=testPassword; |
| 24 | + |
| 25 | + // Step 2: Create first mapping with the new password |
| 26 | + admin |
| 27 | + action="updateMapping" |
| 28 | + type="server" |
| 29 | + password=testPassword |
| 30 | + virtual=testVirtual1 |
| 31 | + physical=testPhysical |
| 32 | + toplevel="true" |
| 33 | + primary="physical"; |
| 34 | + |
| 35 | + // Step 3: Create second mapping with the same password |
| 36 | + // This should NOT fail with "No access, password is invalid" |
| 37 | + // Bug: after first updateMapping, password cache is stale |
| 38 | + admin |
| 39 | + action="updateMapping" |
| 40 | + type="server" |
| 41 | + password=testPassword |
| 42 | + virtual=testVirtual2 |
| 43 | + physical=testPhysical |
| 44 | + toplevel="true" |
| 45 | + primary="physical"; |
| 46 | + |
| 47 | + // Step 4: Verify both mappings exist |
| 48 | + var mappings = []; |
| 49 | + admin |
| 50 | + action="getMappings" |
| 51 | + type="server" |
| 52 | + password=testPassword |
| 53 | + returnVariable="mappings"; |
| 54 | + |
| 55 | + var mapping1Found = false; |
| 56 | + var mapping2Found = false; |
| 57 | + |
| 58 | + for (var mapping in mappings) { |
| 59 | + if (mapping.virtual == testVirtual1) mapping1Found = true; |
| 60 | + if (mapping.virtual == testVirtual2) mapping2Found = true; |
| 61 | + } |
| 62 | + |
| 63 | + expect(mapping1Found).toBe(true, "First mapping should exist"); |
| 64 | + expect(mapping2Found).toBe(true, "Second mapping should exist after second updateMapping"); |
| 65 | + |
| 66 | + } |
| 67 | + catch (any e) { |
| 68 | + fail("Should be able to create multiple mappings after setting password. Error: " & e.message); |
| 69 | + } |
| 70 | + finally { |
| 71 | + // Cleanup: Remove test mappings |
| 72 | + try { |
| 73 | + admin |
| 74 | + action="removeMapping" |
| 75 | + type="server" |
| 76 | + password=testPassword |
| 77 | + virtual=testVirtual1; |
| 78 | + } |
| 79 | + catch (any e) { |
| 80 | + // Ignore cleanup errors |
| 81 | + } |
| 82 | + |
| 83 | + try { |
| 84 | + admin |
| 85 | + action="removeMapping" |
| 86 | + type="server" |
| 87 | + password=testPassword |
| 88 | + virtual=testVirtual2; |
| 89 | + } |
| 90 | + catch (any e) { |
| 91 | + // Ignore cleanup errors |
| 92 | + } |
| 93 | + |
| 94 | + // Remove test directory |
| 95 | + try { |
| 96 | + if (directoryExists(testPhysical)) { |
| 97 | + directoryDelete(testPhysical, true); |
| 98 | + } |
| 99 | + } |
| 100 | + catch (any e) { |
| 101 | + // Ignore cleanup errors |
| 102 | + } |
| 103 | + } |
| 104 | + }); |
| 105 | + }); |
| 106 | + } |
| 107 | +} |
0 commit comments