2929import org .apache .ignite .plugin .security .SecurityPermissionSetBuilder ;
3030import org .junit .Test ;
3131
32+ import static org .apache .ignite .internal .IgniteNodeAttributes .ATTR_BUILD_VER ;
33+ import static org .apache .ignite .plugin .security .SecurityPermission .ADMIN_ROLLING_UPGRADE ;
3234import static org .apache .ignite .testframework .GridTestUtils .assertThrows ;
3335
3436/** Test rolling upgrade permissions. */
3537public class RollingUpgradePermissionCheckTest extends AbstractSecurityTest {
3638 /**
3739 * @throws Exception If failed.
3840 */
39- @ Test public void testRollingUpgradePermissions () throws Exception {
40- IgniteEx node = startGrid ("server_test_node" , SecurityPermissionSetBuilder .create ().defaultAllowAll (false ).build (), false );
41+ @ Test public void testRollingUpgradePermissionDenied () throws Exception {
42+ try (IgniteEx node = startGrid ("server_test_node" , SecurityPermissionSetBuilder .create ().defaultAllowAll (false ).build (), false )) {
43+ for (IgniteThrowableConsumer <IgniteEx > c : operations ()) {
44+ Throwable throwable = assertThrows (log , () -> c .accept (node ), IgniteException .class , "Authorization failed" );
4145
42- for (IgniteThrowableConsumer <IgniteEx > c : operations ()) {
43- Throwable throwable = assertThrows (log , () -> c .accept (node ), IgniteException .class , "Authorization failed" );
46+ assertTrue (X .hasCause (throwable , SecurityException .class ));
47+ }
48+ }
49+ }
50+
51+ /**
52+ * @throws Exception If failed.
53+ */
54+ @ Test public void testRollingUpgradePermissionAllowed () throws Exception {
55+ try (IgniteEx node = startGrid ("server_test_node" , SecurityPermissionSetBuilder .create ().defaultAllowAll (false )
56+ .appendSystemPermissions (ADMIN_ROLLING_UPGRADE ).build (), false )) {
4457
45- assertTrue (X .hasCause (throwable , SecurityException .class ));
58+ for (IgniteThrowableConsumer <IgniteEx > c : operations ())
59+ c .accept (node );
4660 }
4761 }
4862
@@ -51,7 +65,14 @@ public class RollingUpgradePermissionCheckTest extends AbstractSecurityTest {
5165 */
5266 private List <IgniteThrowableConsumer <IgniteEx >> operations () {
5367 return Arrays .asList (
54- ign -> ign .context ().rollingUpgrade ().enable (IgniteProductVersion .fromString ("2.18.0" )),
68+ ign -> {
69+ IgniteProductVersion curVer = IgniteProductVersion .fromString (ign .localNode ().attribute (ATTR_BUILD_VER ));
70+
71+ String targetVerStr = curVer .major () + "." + (curVer .minor () + 1 ) + ".0" ;
72+ IgniteProductVersion targetVer = IgniteProductVersion .fromString (targetVerStr );
73+
74+ ign .context ().rollingUpgrade ().enable (targetVer , false );
75+ },
5576 ign -> ign .context ().rollingUpgrade ().disable ()
5677 );
5778 }
0 commit comments