You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2016/04/15 22:04:10 UTC
[18/22] nifi git commit: NIFI-1551: - Removing the AuthorityProvider.
- Refactoring REST API in preparation for introduction of the Authorizer. -
Updating UI accordingly. - Removing unneeded properties from nifi.properties.
- Addressing comments from PR.
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/xsd/authority-providers.xsd
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/xsd/authority-providers.xsd b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/xsd/authority-providers.xsd
deleted file mode 100644
index 1a5fe50..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/main/xsd/authority-providers.xsd
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <!-- role -->
- <xs:complexType name="Provider">
- <xs:sequence>
- <xs:element name="identifier" type="AuthorityProviderNonEmptyStringType"/>
- <xs:element name="class" type="AuthorityProviderNonEmptyStringType"/>
- <xs:element name="property" type="AuthorityProviderProperty" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
-
- <!-- Name/Value properties-->
- <xs:complexType name="AuthorityProviderProperty">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="name" type="AuthorityProviderNonEmptyStringType"></xs:attribute>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:simpleType name="AuthorityProviderNonEmptyStringType">
- <xs:restriction base="xs:string">
- <xs:minLength value="1"/>
- </xs:restriction>
- </xs:simpleType>
-
- <!-- users -->
- <xs:element name="authorityProviders">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="provider" type="Provider" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-</xs:schema>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java
deleted file mode 100644
index 8d3c15a..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/AuthorizeUserActionTest.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.Set;
-import org.apache.nifi.admin.dao.AuthorityDAO;
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.DataAccessException;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.admin.service.AccountDisabledException;
-import org.apache.nifi.admin.service.AccountNotFoundException;
-import org.apache.nifi.admin.service.AccountPendingException;
-import org.apache.nifi.admin.service.AdministrationException;
-import org.apache.nifi.authorization.Authority;
-import org.apache.nifi.authorization.AuthorityProvider;
-import org.apache.nifi.authorization.exception.AuthorityAccessException;
-import org.apache.nifi.authorization.exception.UnknownIdentityException;
-import org.apache.nifi.user.AccountStatus;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- *
- */
-public class AuthorizeUserActionTest {
-
- private static final String USER_ID_6 = "6";
- private static final String USER_ID_7 = "7";
- private static final String USER_ID_8 = "8";
- private static final String USER_ID_9 = "9";
- private static final String USER_ID_10 = "10";
- private static final String USER_ID_11 = "11";
-
- private static final String USER_IDENTITY_1 = "authority access exception while searching for user";
- private static final String USER_IDENTITY_2 = "unknown user";
- private static final String USER_IDENTITY_3 = "user removed after checking existence";
- private static final String USER_IDENTITY_4 = "access exception getting authorities";
- private static final String USER_IDENTITY_5 = "error creating user account";
- private static final String USER_IDENTITY_6 = "create user general sequence";
- private static final String USER_IDENTITY_7 = "existing user requires verification";
- private static final String USER_IDENTITY_8 = "existing user does not require verification";
- private static final String USER_IDENTITY_9 = "existing pending user";
- private static final String USER_IDENTITY_10 = "existing disabled user";
- private static final String USER_IDENTITY_11 = "existing user is now unknown in the authority provider";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
- private AuthorityDAO authorityDao;
- private AuthorityProvider authorityProvider;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String id = (String) args[0];
-
- NiFiUser user = null;
- if (USER_ID_7.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_7);
- user.setIdentity(USER_IDENTITY_7);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- } else if (USER_ID_8.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_8);
- user.setIdentity(USER_IDENTITY_8);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setLastVerified(new Date());
- } else if (USER_ID_11.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_11);
- user.setIdentity(USER_IDENTITY_11);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- }
-
- return user;
- }
- }).when(userDao).findUserById(Mockito.anyString());
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- NiFiUser user = null;
- switch (dn) {
- case USER_IDENTITY_7:
- user = new NiFiUser();
- user.setId(USER_ID_7);
- user.setIdentity(USER_IDENTITY_7);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- break;
- case USER_IDENTITY_8:
- user = new NiFiUser();
- user.setId(USER_ID_8);
- user.setIdentity(USER_IDENTITY_8);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setLastVerified(new Date());
- break;
- case USER_IDENTITY_9:
- user = new NiFiUser();
- user.setId(USER_ID_9);
- user.setIdentity(USER_IDENTITY_9);
- user.setStatus(AccountStatus.PENDING);
- break;
- case USER_IDENTITY_10:
- user = new NiFiUser();
- user.setId(USER_ID_10);
- user.setIdentity(USER_IDENTITY_10);
- user.setStatus(AccountStatus.DISABLED);
- break;
- case USER_IDENTITY_11:
- user = new NiFiUser();
- user.setId(USER_ID_11);
- user.setIdentity(USER_IDENTITY_11);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- break;
- }
-
- return user;
- }
- }).when(userDao).findUserByDn(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
- switch (user.getIdentity()) {
- case USER_IDENTITY_5:
- throw new DataAccessException();
- case USER_IDENTITY_6:
- user.setId(USER_ID_6);
- break;
- }
-
- // do nothing
- return null;
- }
- }).when(userDao).createUser(Mockito.any(NiFiUser.class));
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- // do nothing
- return null;
- }
- }).when(userDao).updateUser(Mockito.any(NiFiUser.class));
-
- // mock the authority dao
- authorityDao = Mockito.mock(AuthorityDAO.class);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Set<Authority> authorities = (Set<Authority>) args[0];
- String id = (String) args[1];
-
- // do nothing
- return null;
- }
- }).when(authorityDao).createAuthorities(Mockito.anySetOf(Authority.class), Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Set<Authority> authorities = (Set<Authority>) args[0];
- String id = (String) args[1];
-
- // do nothing
- return null;
- }
- }).when(authorityDao).deleteAuthorities(Mockito.anySetOf(Authority.class), Mockito.anyString());
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- Mockito.when(daoFactory.getAuthorityDAO()).thenReturn(authorityDao);
-
- // mock the authority provider
- authorityProvider = Mockito.mock(AuthorityProvider.class);
- Mockito.doAnswer(new Answer<Boolean>() {
- @Override
- public Boolean answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
- switch (dn) {
- case USER_IDENTITY_1:
- throw new AuthorityAccessException(StringUtils.EMPTY);
- case USER_IDENTITY_2:
- return false;
- }
-
- return true;
- }
- }).when(authorityProvider).doesDnExist(Mockito.anyString());
- Mockito.doAnswer(new Answer<Set<Authority>>() {
- @Override
- public Set<Authority> answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
- Set<Authority> authorities = EnumSet.noneOf(Authority.class);
- switch (dn) {
- case USER_IDENTITY_3:
- throw new UnknownIdentityException(StringUtils.EMPTY);
- case USER_IDENTITY_4:
- throw new AuthorityAccessException(StringUtils.EMPTY);
- case USER_IDENTITY_6:
- authorities.add(Authority.ROLE_MONITOR);
- break;
- case USER_IDENTITY_7:
- authorities.add(Authority.ROLE_DFM);
- break;
- case USER_IDENTITY_9:
- throw new UnknownIdentityException(StringUtils.EMPTY);
- case USER_IDENTITY_10:
- throw new UnknownIdentityException(StringUtils.EMPTY);
- case USER_IDENTITY_11:
- throw new UnknownIdentityException(StringUtils.EMPTY);
- }
-
- return authorities;
- }
- }).when(authorityProvider).getAuthorities(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
- Set<Authority> authorites = (Set<Authority>) args[1];
-
- // do nothing
- return null;
- }
- }).when(authorityProvider).setAuthorities(Mockito.anyString(), Mockito.anySet());
- }
-
- /**
- * Tests AuthorityAccessException in doesDnExist.
- *
- * @throws Exception ex
- */
- @Test(expected = AdministrationException.class)
- public void testAuthorityAccessExceptionInDoesDnExist() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_1, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Test unknown user in the authority provider.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountNotFoundException.class)
- public void testUnknownUser() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_2, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Test a user thats been removed after checking their existence.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountNotFoundException.class)
- public void testUserRemovedAfterCheckingExistence() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_3, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Testing AuthorityAccessException when getting authorities.
- *
- * @throws Exception ex
- */
- @Test(expected = AdministrationException.class)
- public void testAuthorityAccessException() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_4, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Testing DataAccessException while creating user accounts.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testErrorCreatingUserAccount() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_5, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests the general case when a user account is created.
- *
- * @throws Exception ex
- */
- @Test
- public void testAccountCreation() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_6, 0);
- NiFiUser user = authorizeUser.execute(daoFactory, authorityProvider);
-
- // verify the user
- Assert.assertEquals(USER_IDENTITY_6, user.getIdentity());
- Assert.assertEquals(1, user.getAuthorities().size());
- Assert.assertTrue(user.getAuthorities().contains(Authority.ROLE_MONITOR));
-
- // verify interaction with dao and provider
- Mockito.verify(userDao, Mockito.times(1)).createUser(user);
- }
-
- /**
- * Tests the general case when there is an existing user account that
- * requires verification.
- *
- * @throws Exception ex
- */
- @Test
- public void testExistingUserRequiresVerification() throws Exception {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_7, 0);
- NiFiUser user = authorizeUser.execute(daoFactory, authorityProvider);
-
- // verify the user
- Assert.assertEquals(USER_IDENTITY_7, user.getIdentity());
- Assert.assertEquals(1, user.getAuthorities().size());
- Assert.assertTrue(user.getAuthorities().contains(Authority.ROLE_DFM));
-
- // verify interaction with dao and provider
- Mockito.verify(userDao, Mockito.times(1)).updateUser(user);
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(EnumSet.of(Authority.ROLE_DFM), USER_ID_7);
- }
-
- /**
- * Tests the general case when there is an existing user account that does
- * not require verification.
- *
- * @throws Exception ex
- */
- @Test
- public void testExistingUserNoVerification() throws Exception {
- // disabling verification by passing in a large cache duration
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_8, Integer.MAX_VALUE);
- NiFiUser user = authorizeUser.execute(daoFactory, authorityProvider);
-
- // verify the user
- Assert.assertEquals(USER_IDENTITY_8, user.getIdentity());
- Assert.assertEquals(1, user.getAuthorities().size());
- Assert.assertTrue(user.getAuthorities().contains(Authority.ROLE_MONITOR));
-
- // verify interaction with dao and provider
- Mockito.verify(userDao, Mockito.times(1)).updateUser(user);
- Mockito.verify(authorityDao, Mockito.never()).createAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_8));
- Mockito.verify(authorityDao, Mockito.never()).deleteAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_8));
- }
-
- /**
- * Tests existing users whose accounts are in a pending status.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountPendingException.class)
- public void testExistingPendingUser() throws Exception {
- // disabling verification by passing in a large cache duration
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_9, Integer.MAX_VALUE);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests existing users whose accounts are in a disabled status.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountDisabledException.class)
- public void testExistingDisabledUser() throws Exception {
- // disabling verification by passing in a large cache duration
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_10, Integer.MAX_VALUE);
- authorizeUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests the general case where there is an active user that has been
- * removed from the authority provider.
- *
- * @throws Exception ex
- */
- @Test
- public void testExistingActiveUserNotFoundInProvider() throws Exception {
- try {
- AuthorizeUserAction authorizeUser = new AuthorizeUserAction(USER_IDENTITY_11, 0);
- authorizeUser.execute(daoFactory, authorityProvider);
-
- Assert.fail();
- } catch (AccountDisabledException ade) {
- ArgumentCaptor<NiFiUser> user = ArgumentCaptor.forClass(NiFiUser.class);
-
- // verify interaction with dao
- Mockito.verify(userDao, Mockito.times(1)).updateUser(user.capture());
-
- // verify user
- Assert.assertEquals(AccountStatus.DISABLED, user.getValue().getStatus());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java
deleted file mode 100644
index e372781..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/CreateUserActionTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import java.util.EnumSet;
-import java.util.Set;
-import org.apache.nifi.admin.dao.AuthorityDAO;
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.DataAccessException;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.authorization.Authority;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Test cases for creating a user.
- */
-public class CreateUserActionTest {
-
- private final String USER_ID_2 = "2";
- private final String USER_ID_3 = "3";
-
- private final String USER_IDENTITY_1 = "data access exception when creating user";
- private final String USER_IDENTITY_3 = "general create user case";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
- private AuthorityDAO authorityDao;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- if (USER_IDENTITY_1.equals(user.getIdentity())) {
- throw new DataAccessException();
- } else if (USER_IDENTITY_3.equals(user.getIdentity())) {
- user.setId(USER_ID_3);
- }
-
- // do nothing
- return null;
- }
- }).when(userDao).createUser(Mockito.any(NiFiUser.class));
-
- // mock the authority dao
- authorityDao = Mockito.mock(AuthorityDAO.class);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Set<Authority> authorities = (Set<Authority>) args[0];
- String id = (String) args[1];
-
- if (USER_ID_2.equals(id)) {
- throw new DataAccessException(StringUtils.EMPTY);
- }
-
- // do nothing
- return null;
- }
- }).when(authorityDao).createAuthorities(Mockito.anySetOf(Authority.class), Mockito.anyString());
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- Mockito.when(daoFactory.getAuthorityDAO()).thenReturn(authorityDao);
- }
-
- /**
- * Tests DataAccessExceptions that occur while creating user accounts.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testExceptionCreatingUser() throws Exception {
- NiFiUser user = new NiFiUser();
- user.setIdentity(USER_IDENTITY_1);
-
- CreateUserAction createUser = new CreateUserAction(user);
- createUser.execute(daoFactory, null);
- }
-
- /**
- * Tests DataAccessExceptions that occur while create user authorities.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testExceptionCreatingAuthoroties() throws Exception {
- NiFiUser user = new NiFiUser();
- user.setId(USER_ID_2);
-
- CreateUserAction createUser = new CreateUserAction(user);
- createUser.execute(daoFactory, null);
- }
-
- /**
- * General case for creating a user.
- *
- * @throws Exception ex
- */
- @Test
- public void testCreateUserAccount() throws Exception {
- NiFiUser user = new NiFiUser();
- user.setIdentity(USER_IDENTITY_3);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_DFM, Authority.ROLE_ADMIN));
-
- CreateUserAction createUser = new CreateUserAction(user);
- createUser.execute(daoFactory, null);
-
- // verify the user
- Assert.assertEquals(USER_ID_3, user.getId());
-
- // verify interaction with dao
- Mockito.verify(userDao, Mockito.times(1)).createUser(user);
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(user.getAuthorities(), USER_ID_3);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java
deleted file mode 100644
index b5f0a7f..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/DisableUserActionTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.DataAccessException;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.admin.service.AccountNotFoundException;
-import org.apache.nifi.admin.service.AdministrationException;
-import org.apache.nifi.authorization.AuthorityProvider;
-import org.apache.nifi.authorization.exception.AuthorityAccessException;
-import org.apache.nifi.user.AccountStatus;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.nifi.admin.dao.KeyDAO;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-public class DisableUserActionTest {
-
- private static final String USER_ID_1 = "1";
- private static final String USER_ID_2 = "2";
- private static final String USER_ID_3 = "3";
- private static final String USER_ID_4 = "4";
-
- private static final String USER_IDENTITY_3 = "authority access exception";
- private static final String USER_IDENTITY_4 = "general disable user case";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
- private KeyDAO keyDao;
- private AuthorityProvider authorityProvider;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String id = (String) args[0];
-
- NiFiUser user = null;
- if (USER_ID_1.equals(id)) {
- // leave user uninitialized
- } else if (USER_ID_2.equals(id)) {
- user = new NiFiUser();
- user.setId(id);
- } else if (USER_ID_3.equals(id)) {
- user = new NiFiUser();
- user.setId(id);
- user.setIdentity(USER_IDENTITY_3);
- } else if (USER_ID_4.equals(id)) {
- user = new NiFiUser();
- user.setId(id);
- user.setIdentity(USER_IDENTITY_4);
- user.setStatus(AccountStatus.ACTIVE);
- }
- return user;
- }
- }).when(userDao).findUserById(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- if (USER_ID_2.equals(user.getId())) {
- throw new DataAccessException(StringUtils.EMPTY);
- }
-
- // do nothing
- return null;
- }
- }).when(userDao).updateUser(Mockito.any(NiFiUser.class));
-
- // mock the dao factory
- keyDao = Mockito.mock(KeyDAO.class);
- Mockito.doNothing().when(keyDao).deleteKeys(Matchers.anyString());
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- Mockito.when(daoFactory.getKeyDAO()).thenReturn(keyDao);
-
- // mock the authority provider
- authorityProvider = Mockito.mock(AuthorityProvider.class);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- if (USER_IDENTITY_3.equals(dn)) {
- throw new AuthorityAccessException(StringUtils.EMPTY);
- }
-
- // do nothing
- return null;
- }
- }).when(authorityProvider).revokeUser(Mockito.anyString());
- }
-
- /**
- * Tests the case when the user account is unknown.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountNotFoundException.class)
- public void testUnknownUserAccount() throws Exception {
- DisableUserAction disableUser = new DisableUserAction(USER_ID_1);
- disableUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests the case when a DataAccessException is thrown by the userDao.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testDataAccessExceptionInUserDao() throws Exception {
- DisableUserAction disableUser = new DisableUserAction(USER_ID_2);
- disableUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests the case when a AuthorityAccessException is thrown by the provider.
- *
- * @throws Exception ex
- */
- @Test(expected = AdministrationException.class)
- public void testAuthorityAccessExceptionInProvider() throws Exception {
- DisableUserAction disableUser = new DisableUserAction(USER_ID_3);
- disableUser.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests the general case when the user is disabled.
- *
- * @throws Exception ex
- */
- @Test
- public void testDisableUser() throws Exception {
- DisableUserAction disableUser = new DisableUserAction(USER_ID_4);
- NiFiUser user = disableUser.execute(daoFactory, authorityProvider);
-
- // verify the user
- Assert.assertEquals(USER_ID_4, user.getId());
- Assert.assertEquals(USER_IDENTITY_4, user.getIdentity());
- Assert.assertEquals(AccountStatus.DISABLED, user.getStatus());
-
- // verify the interaction with the dao and provider
- Mockito.verify(userDao, Mockito.times(1)).updateUser(user);
- Mockito.verify(authorityProvider, Mockito.times(1)).revokeUser(USER_IDENTITY_4);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java
deleted file mode 100644
index cffd280..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/InvalidateUserAccountActionTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import java.util.Date;
-import org.junit.Assert;
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.DataAccessException;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.admin.service.AccountNotFoundException;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Test case for InvalidateUserAccountAction.
- */
-public class InvalidateUserAccountActionTest {
-
- private static final String USER_ID_1 = "1";
- private static final String USER_ID_2 = "2";
- private static final String USER_ID_3 = "3";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String id = (String) args[0];
-
- NiFiUser user = null;
- if (USER_ID_1.equals(id)) {
- // leave uninitialized
- } else if (USER_ID_2.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_2);
- } else if (USER_ID_3.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_3);
- user.setLastVerified(new Date());
- }
- return user;
- }
- }).when(userDao).findUserById(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- if (USER_ID_2.equals(user.getId())) {
- throw new DataAccessException(StringUtils.EMPTY);
- }
-
- // do nothing
- return null;
- }
- }).when(userDao).updateUser(Mockito.any(NiFiUser.class));
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- }
-
- @Test(expected = AccountNotFoundException.class)
- public void testAccountNotFoundException() throws Exception {
- InvalidateUserAccountAction invalidateUserAccount = new InvalidateUserAccountAction(USER_ID_1);
- invalidateUserAccount.execute(daoFactory, null);
- }
-
- /**
- * Tests when a data access exception occurs when updating the user record.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testDataAccessException() throws Exception {
- InvalidateUserAccountAction invalidateUserAccount = new InvalidateUserAccountAction(USER_ID_2);
- invalidateUserAccount.execute(daoFactory, null);
- }
-
- /**
- * Tests the general case of invalidating a user.
- *
- * @throws Exception ex
- */
- @Test
- public void testInvalidateUser() throws Exception {
- InvalidateUserAccountAction invalidateUserAccount = new InvalidateUserAccountAction(USER_ID_3);
- invalidateUserAccount.execute(daoFactory, null);
-
- // verify the interaction with the dao
- ArgumentCaptor<NiFiUser> userCaptor = ArgumentCaptor.forClass(NiFiUser.class);
- Mockito.verify(userDao, Mockito.times(1)).updateUser(userCaptor.capture());
-
- // verify the user
- NiFiUser user = userCaptor.getValue();
- Assert.assertEquals(USER_ID_3, user.getId());
- Assert.assertNull(user.getLastVerified());
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java
deleted file mode 100644
index 7bc863b..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/RequestUserAccountActionTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.DataAccessException;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.user.AccountStatus;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Test case for RequestUserAccountAction.
- */
-public class RequestUserAccountActionTest {
-
- private static final String USER_ID_3 = "3";
-
- private static final String USER_IDENTITY_1 = "existing user account";
- private static final String USER_IDENTITY_2 = "data access exception";
- private static final String USER_IDENTITY_3 = "new account request";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- NiFiUser user = null;
- if (USER_IDENTITY_1.equals(dn)) {
- user = new NiFiUser();
- }
- return user;
- }
- }).when(userDao).findUserByDn(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
- switch (user.getIdentity()) {
- case USER_IDENTITY_2:
- throw new DataAccessException();
- case USER_IDENTITY_3:
- user.setId(USER_ID_3);
- break;
- }
-
- // do nothing
- return null;
- }
- }).when(userDao).createUser(Mockito.any(NiFiUser.class));
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- }
-
- /**
- * Tests when a user account already exists.
- *
- * @throws Exception ex
- */
- @Test(expected = IllegalArgumentException.class)
- public void testExistingAccount() throws Exception {
- RequestUserAccountAction requestUserAccount = new RequestUserAccountAction(USER_IDENTITY_1, StringUtils.EMPTY);
- requestUserAccount.execute(daoFactory, null);
- }
-
- /**
- * Tests when a DataAccessException occurs while saving the new account
- * request.
- *
- * @throws Exception ex
- */
- @Test(expected = DataAccessException.class)
- public void testDataAccessException() throws Exception {
- RequestUserAccountAction requestUserAccount = new RequestUserAccountAction(USER_IDENTITY_2, StringUtils.EMPTY);
- requestUserAccount.execute(daoFactory, null);
- }
-
- /**
- * Tests the general case for requesting a new user account.
- *
- * @throws Exception ex
- */
- @Test
- public void testRequestUserAccountAction() throws Exception {
- RequestUserAccountAction requestUserAccount = new RequestUserAccountAction(USER_IDENTITY_3, StringUtils.EMPTY);
- NiFiUser user = requestUserAccount.execute(daoFactory, null);
-
- // verfiy the user
- Assert.assertEquals(USER_ID_3, user.getId());
- Assert.assertEquals(USER_IDENTITY_3, user.getIdentity());
- Assert.assertEquals(AccountStatus.PENDING, user.getStatus());
-
- // verify interaction with dao
- Mockito.verify(userDao, Mockito.times(1)).createUser(user);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java
deleted file mode 100644
index 58db56a..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SeedUserAccountsActionTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
-import org.apache.nifi.admin.dao.AuthorityDAO;
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.authorization.Authority;
-import org.apache.nifi.authorization.AuthorityProvider;
-import org.apache.nifi.user.AccountStatus;
-import org.apache.nifi.user.NiFiUser;
-import org.hamcrest.Matcher;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentMatcher;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- *
- */
-public class SeedUserAccountsActionTest {
-
- private static final String USER_ID_1 = "1";
- private static final String USER_ID_2 = "2";
- private static final String USER_ID_3 = "3";
- private static final String USER_ID_4 = "4";
-
- private static final String USER_IDENTITY_1 = "user 1 - active user - remove monitor and operator, add dfm";
- private static final String USER_IDENTITY_2 = "user 2 - active user - no action";
- private static final String USER_IDENTITY_3 = "user 3 - pending user - add operator";
- private static final String USER_IDENTITY_4 = "user 4 - new user - add monitor";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
- private AuthorityDAO authorityDao;
- private AuthorityProvider authorityProvider;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String id = (String) args[0];
-
- NiFiUser user = null;
- if (USER_ID_1.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_1);
- user.setIdentity(USER_IDENTITY_1);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- } else if (USER_ID_2.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_2);
- user.setIdentity(USER_IDENTITY_2);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_ADMIN));
- user.setStatus(AccountStatus.ACTIVE);
- } else if (USER_ID_3.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_3);
- user.setIdentity(USER_IDENTITY_3);
- user.setStatus(AccountStatus.PENDING);
- }
- return user;
- }
- }).when(userDao).findUserById(Mockito.anyString());
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- NiFiUser user = null;
- if (USER_IDENTITY_1.equals(dn)) {
- user = new NiFiUser();
- user.setId(USER_ID_1);
- user.setIdentity(USER_IDENTITY_1);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- } else if (USER_IDENTITY_2.equals(dn)) {
- user = new NiFiUser();
- user.setId(USER_ID_2);
- user.setIdentity(USER_IDENTITY_2);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_ADMIN));
- user.setStatus(AccountStatus.ACTIVE);
- } else if (USER_IDENTITY_3.equals(dn)) {
- user = new NiFiUser();
- user.setId(USER_ID_3);
- user.setIdentity(USER_IDENTITY_3);
- user.setStatus(AccountStatus.PENDING);
- }
- return user;
- }
- }).when(userDao).findUserByDn(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- if (USER_IDENTITY_4.equals(user.getIdentity())) {
- user.setId(USER_ID_4);
- }
-
- return null;
- }
- }).when(userDao).createUser(Mockito.any(NiFiUser.class));
-
- // mock the authority dao
- authorityDao = Mockito.mock(AuthorityDAO.class);
-
- // mock the authority provider
- authorityProvider = Mockito.mock(AuthorityProvider.class);
- Mockito.doAnswer(new Answer<Set<String>>() {
- @Override
- public Set<String> answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Authority role = (Authority) args[0];
-
- Set<String> users = new HashSet<>();
- if (Authority.ROLE_DFM.equals(role)) {
- users.add(USER_IDENTITY_1);
- } else if (Authority.ROLE_ADMIN.equals(role)) {
- users.add(USER_IDENTITY_2);
- } else if (Authority.ROLE_PROXY.equals(role)) {
- users.add(USER_IDENTITY_3);
- } else if (Authority.ROLE_MONITOR.equals(role)) {
- users.add(USER_IDENTITY_4);
- }
- return users;
- }
- }).when(authorityProvider).getUsers(Mockito.any(Authority.class));
- Mockito.doAnswer(new Answer<Set<Authority>>() {
- @Override
- public Set<Authority> answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- Set<Authority> authorities = EnumSet.noneOf(Authority.class);
- switch (dn) {
- case USER_IDENTITY_1:
- authorities.add(Authority.ROLE_DFM);
- break;
- case USER_IDENTITY_2:
- authorities.add(Authority.ROLE_ADMIN);
- break;
- case USER_IDENTITY_3:
- authorities.add(Authority.ROLE_PROXY);
- break;
- case USER_IDENTITY_4:
- authorities.add(Authority.ROLE_MONITOR);
- break;
- }
- return authorities;
- }
- }).when(authorityProvider).getAuthorities(Mockito.anyString());
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- Mockito.when(daoFactory.getAuthorityDAO()).thenReturn(authorityDao);
- }
-
- /**
- * Tests seeding the user accounts.
- *
- * @throws Exception ex
- */
- @Test
- public void testSeedUsers() throws Exception {
- SeedUserAccountsAction seedUserAccounts = new SeedUserAccountsAction();
- seedUserAccounts.execute(daoFactory, authorityProvider);
-
- // matcher for user 1
- Matcher<NiFiUser> matchesUser1 = new ArgumentMatcher<NiFiUser>() {
- @Override
- public boolean matches(Object argument) {
- NiFiUser user = (NiFiUser) argument;
- return USER_ID_1.equals(user.getId());
- }
- };
-
- // verify user 1 - active existing user - remove monitor, operator, add dfm
- Mockito.verify(userDao, Mockito.times(1)).updateUser(Mockito.argThat(matchesUser1));
- Mockito.verify(userDao, Mockito.never()).createUser(Mockito.argThat(matchesUser1));
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(EnumSet.of(Authority.ROLE_DFM), USER_ID_1);
-
- // matcher for user 2
- Matcher<NiFiUser> matchesUser2 = new ArgumentMatcher<NiFiUser>() {
- @Override
- public boolean matches(Object argument) {
- NiFiUser user = (NiFiUser) argument;
- return USER_ID_2.equals(user.getId());
- }
- };
-
- // verify user 2 - active existing user - no actions
- Mockito.verify(userDao, Mockito.times(1)).updateUser(Mockito.argThat(matchesUser2));
- Mockito.verify(userDao, Mockito.never()).createUser(Mockito.argThat(matchesUser2));
- Mockito.verify(authorityDao, Mockito.never()).createAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_2));
- Mockito.verify(authorityDao, Mockito.never()).deleteAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_2));
-
- // matchers for user 3
- Matcher<NiFiUser> matchesPendingUser3 = new ArgumentMatcher<NiFiUser>() {
- @Override
- public boolean matches(Object argument) {
- NiFiUser user = (NiFiUser) argument;
- return USER_ID_3.equals(user.getId()) && AccountStatus.ACTIVE.equals(user.getStatus());
- }
- };
- Matcher<NiFiUser> matchesUser3 = new ArgumentMatcher<NiFiUser>() {
- @Override
- public boolean matches(Object argument) {
- NiFiUser user = (NiFiUser) argument;
- return USER_ID_3.equals(user.getId());
- }
- };
-
- // verify user 3 - pending user - add operator
- Mockito.verify(userDao, Mockito.times(1)).updateUser(Mockito.argThat(matchesPendingUser3));
- Mockito.verify(userDao, Mockito.never()).createUser(Mockito.argThat(matchesUser3));
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(EnumSet.of(Authority.ROLE_PROXY), USER_ID_3);
- Mockito.verify(authorityDao, Mockito.never()).deleteAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_3));
-
- // matcher for user 4
- Matcher<NiFiUser> matchesUser4 = new ArgumentMatcher<NiFiUser>() {
- @Override
- public boolean matches(Object argument) {
- NiFiUser user = (NiFiUser) argument;
- return USER_ID_4.equals(user.getId());
- }
- };
-
- // verify user 4 - new user - add monitor
- Mockito.verify(userDao, Mockito.never()).updateUser(Mockito.argThat(matchesUser4));
- Mockito.verify(userDao, Mockito.times(1)).createUser(Mockito.argThat(matchesUser4));
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(EnumSet.of(Authority.ROLE_MONITOR), USER_ID_4);
- Mockito.verify(authorityDao, Mockito.never()).deleteAuthorities(Mockito.anySet(), Mockito.eq(USER_ID_4));
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java
deleted file mode 100644
index 5effdbb..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-administration/src/test/java/org/apache/nifi/admin/service/action/SetUserAuthoritiesActionTest.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.admin.service.action;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Set;
-import org.apache.nifi.admin.dao.AuthorityDAO;
-import org.apache.nifi.admin.dao.DAOFactory;
-import org.apache.nifi.admin.dao.UserDAO;
-import org.apache.nifi.admin.service.AccountNotFoundException;
-import org.apache.nifi.admin.service.AdministrationException;
-import org.apache.nifi.authorization.Authority;
-import org.apache.nifi.authorization.AuthorityProvider;
-import org.apache.nifi.authorization.exception.AuthorityAccessException;
-import org.apache.nifi.user.AccountStatus;
-import org.apache.nifi.user.NiFiUser;
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-/**
- * Test case for SetUserAuthoritiesAction.
- */
-public class SetUserAuthoritiesActionTest {
-
- private static final String USER_ID_1 = "1";
- private static final String USER_ID_2 = "2";
- private static final String USER_ID_3 = "3";
-
- private static final String USER_IDENTITY_2 = "user 2";
- private static final String USER_IDENTITY_3 = "user 3";
-
- private DAOFactory daoFactory;
- private UserDAO userDao;
- private AuthorityDAO authorityDao;
- private AuthorityProvider authorityProvider;
-
- @Before
- public void setup() throws Exception {
- // mock the user dao
- userDao = Mockito.mock(UserDAO.class);
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String id = (String) args[0];
-
- NiFiUser user = null;
- if (USER_ID_1.equals(id)) {
- // leave user uninitialized
- } else if (USER_ID_2.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_2);
- user.setIdentity(USER_IDENTITY_2);
- } else if (USER_ID_3.equals(id)) {
- user = new NiFiUser();
- user.setId(USER_ID_3);
- user.setIdentity(USER_IDENTITY_3);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- }
- return user;
- }
- }).when(userDao).findUserById(Mockito.anyString());
- Mockito.doAnswer(new Answer<NiFiUser>() {
- @Override
- public NiFiUser answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- NiFiUser user = null;
- if (USER_IDENTITY_3.equals(dn)) {
- user = new NiFiUser();
- user.setId(USER_ID_3);
- user.setIdentity(USER_IDENTITY_3);
- user.getAuthorities().addAll(EnumSet.of(Authority.ROLE_MONITOR));
- user.setStatus(AccountStatus.ACTIVE);
- }
- return user;
- }
- }).when(userDao).findUserByDn(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- NiFiUser user = (NiFiUser) args[0];
-
- // do nothing
- return null;
- }
- }).when(userDao).updateUser(Mockito.any(NiFiUser.class));
-
- // mock the authority dao
- authorityDao = Mockito.mock(AuthorityDAO.class);
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Set<Authority> authorities = (Set<Authority>) args[0];
- String id = (String) args[1];
-
- // do nothing
- return null;
- }
- }).when(authorityDao).createAuthorities(Mockito.anySetOf(Authority.class), Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- Set<Authority> authorities = (Set<Authority>) args[0];
- String id = (String) args[1];
-
- // do nothing
- return null;
- }
- }).when(authorityDao).deleteAuthorities(Mockito.anySetOf(Authority.class), Mockito.anyString());
-
- // mock the dao factory
- daoFactory = Mockito.mock(DAOFactory.class);
- Mockito.when(daoFactory.getUserDAO()).thenReturn(userDao);
- Mockito.when(daoFactory.getAuthorityDAO()).thenReturn(authorityDao);
-
- // mock the authority provider
- authorityProvider = Mockito.mock(AuthorityProvider.class);
- Mockito.doAnswer(new Answer<Set<Authority>>() {
- @Override
- public Set<Authority> answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
-
- Set<Authority> authorities = EnumSet.noneOf(Authority.class);
- if (USER_IDENTITY_3.equals(dn)) {
- authorities.add(Authority.ROLE_DFM);
- }
-
- return authorities;
- }
- }).when(authorityProvider).getAuthorities(Mockito.anyString());
- Mockito.doAnswer(new Answer<Void>() {
- @Override
- public Void answer(InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
- String dn = (String) args[0];
- Set<Authority> authorites = (Set<Authority>) args[1];
-
- if (USER_IDENTITY_2.equals(dn)) {
- throw new AuthorityAccessException(StringUtils.EMPTY);
- }
-
- // do nothing
- return null;
- }
- }).when(authorityProvider).setAuthorities(Mockito.anyString(), Mockito.anySet());
- }
-
- /**
- * Test activating an unknown user account. User accounts are unknown then
- * there is no pending account for the user.
- *
- * @throws Exception ex
- */
- @Test(expected = AccountNotFoundException.class)
- public void testUnknownUser() throws Exception {
- UpdateUserAction setUserAuthorities = new UpdateUserAction(USER_ID_1, Collections.EMPTY_SET);
- setUserAuthorities.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Testing case then an AuthorityAccessException occurs while setting a
- * users authorities.
- *
- * @throws Exception ex
- */
- @Test(expected = AdministrationException.class)
- public void testAuthorityAccessException() throws Exception {
- UpdateUserAction setUserAuthorities = new UpdateUserAction(USER_ID_2, Collections.EMPTY_SET);
- setUserAuthorities.execute(daoFactory, authorityProvider);
- }
-
- /**
- * Tests general case of setting user authorities.
- *
- * @throws Exception ex
- */
- @Test
- public void testSetAuthorities() throws Exception {
- UpdateUserAction setUserAuthorities = new UpdateUserAction(USER_ID_3, EnumSet.of(Authority.ROLE_ADMIN));
- NiFiUser user = setUserAuthorities.execute(daoFactory, authorityProvider);
-
- // verify user
- Assert.assertEquals(USER_ID_3, user.getId());
- Assert.assertEquals(1, user.getAuthorities().size());
- Assert.assertTrue(user.getAuthorities().contains(Authority.ROLE_ADMIN));
-
- // verify interaction with dao
- Mockito.verify(userDao, Mockito.times(1)).updateUser(user);
- Mockito.verify(authorityDao, Mockito.times(1)).createAuthorities(EnumSet.of(Authority.ROLE_ADMIN), USER_ID_3);
-
- Set<Authority> authoritiesAddedToProvider = EnumSet.of(Authority.ROLE_ADMIN);
-
- // verify interaction with provider
- Mockito.verify(authorityProvider, Mockito.times(1)).setAuthorities(USER_IDENTITY_3, authoritiesAddedToProvider);
- }
-}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java
index c8ef843..200c954 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java
@@ -18,6 +18,7 @@ package org.apache.nifi.web.api.dto;
import com.wordnik.swagger.annotations.ApiModelProperty;
import javax.xml.bind.annotation.XmlType;
+import java.util.UUID;
/**
* Current revision for this NiFi.
@@ -41,6 +42,9 @@ public class RevisionDTO {
+ "nature of requests/responses this was implemented to allow the client to make numerous requests without having to wait for the previous response to come back"
)
public String getClientId() {
+ if (clientId == null || clientId.trim().isEmpty()) {
+ clientId = UUID.randomUUID().toString();
+ }
return clientId;
}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java
index 03e2124..cec51e5 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/status/ControllerStatusDTO.java
@@ -38,8 +38,6 @@ public class ControllerStatusDTO implements Cloneable {
private Integer connectedNodeCount = 0;
private Integer totalNodeCount = 0;
- private Boolean hasPendingAccounts;
-
private Integer runningCount = 0;
private Integer stoppedCount = 0;
private Integer invalidCount = 0;
@@ -127,18 +125,6 @@ public class ControllerStatusDTO implements Cloneable {
}
/**
- * @return whether or not there are pending user requests
- */
- @ApiModelProperty("Whether there are any pending user account requests.")
- public Boolean getHasPendingAccounts() {
- return hasPendingAccounts;
- }
-
- public void setHasPendingAccounts(Boolean hasPendingAccounts) {
- this.hasPendingAccounts = hasPendingAccounts;
- }
-
- /**
* @return number of running components in this controller
*/
@ApiModelProperty("The number of running components in the NiFi.")
@@ -256,7 +242,6 @@ public class ControllerStatusDTO implements Cloneable {
other.setConnectedNodes(getConnectedNodes());
other.setConnectedNodeCount(getConnectedNodeCount());
other.setTotalNodeCount(getTotalNodeCount());
- other.setHasPendingAccounts(getHasPendingAccounts());
other.setRunningCount(getRunningCount());
other.setStoppedCount(getStoppedCount());
other.setInvalidCount(getInvalidCount());
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java
index ad3a7de..13c7a70 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/Entity.java
@@ -35,7 +35,11 @@ public class Entity {
value = "The revision for this request/response. The revision is required for any mutable flow requests and is included in all responses."
)
public RevisionDTO getRevision() {
- return revision;
+ if (revision == null) {
+ return new RevisionDTO();
+ } else {
+ return revision;
+ }
}
public void setRevision(RevisionDTO revision) {
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UpdateControllerServiceReferenceRequestEntity.java
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UpdateControllerServiceReferenceRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UpdateControllerServiceReferenceRequestEntity.java
new file mode 100644
index 0000000..0b2230e
--- /dev/null
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/UpdateControllerServiceReferenceRequestEntity.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.web.api.entity;
+
+import com.wordnik.swagger.annotations.ApiModelProperty;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * A serialized representation of this class can be placed in the entity body of a request to the API.
+ */
+@XmlRootElement(name = "updateControllerServiceReferenceRequestEntity")
+public class UpdateControllerServiceReferenceRequestEntity extends Entity {
+
+ private String id;
+ private String state;
+
+ @ApiModelProperty(
+ value = "The identifier of the Controller Service."
+ )
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @ApiModelProperty(
+ value = "The new state of the references for the controller service.",
+ allowableValues = "ENABLED, DISABLED, RUNNING, STOPPED"
+ )
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+}
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/.gitignore
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/.gitignore b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/.gitignore
deleted file mode 100755
index ea8c4bf..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target
http://git-wip-us.apache.org/repos/asf/nifi/blob/153f63ef/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/pom.xml
----------------------------------------------------------------------
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/pom.xml
deleted file mode 100644
index 2f0147b..0000000
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-cluster-authorization-provider/pom.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-framework</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
- <artifactId>nifi-cluster-authorization-provider</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-file-authorization-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-framework-cluster-protocol</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-framework-cluster</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.nifi</groupId>
- <artifactId>nifi-socket-utils</artifactId>
- </dependency>
- </dependencies>
-</project>