Search in sources :

Example 16 with VpnUser

use of com.cloud.network.VpnUser in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElementTest method testApplyVpnUsersException1.

@Test
public void testApplyVpnUsersException1() {
    vpcVirtualRouterElement._vpcRouterMgr = _vpcRouterMgr;
    final AdvancedNetworkTopology advancedNetworkTopology = Mockito.mock(AdvancedNetworkTopology.class);
    final BasicNetworkTopology basicNetworkTopology = Mockito.mock(BasicNetworkTopology.class);
    networkTopologyContext.setAdvancedNetworkTopology(advancedNetworkTopology);
    networkTopologyContext.setBasicNetworkTopology(basicNetworkTopology);
    networkTopologyContext.init();
    final RemoteAccessVpn remoteAccessVpn = Mockito.mock(RemoteAccessVpn.class);
    final List<VpnUser> users = new ArrayList<>();
    when(remoteAccessVpn.getVpcId()).thenReturn(null);
    try {
        final String[] results = vpcVirtualRouterElement.applyVpnUsers(remoteAccessVpn, users);
        assertNull(results);
    } catch (final ResourceUnavailableException e) {
        fail(e.getMessage());
    }
    verify(remoteAccessVpn, times(1)).getVpcId();
}
Also used : BasicNetworkTopology(com.cloud.network.topology.BasicNetworkTopology) VpnUser(com.cloud.network.VpnUser) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) AdvancedNetworkTopology(com.cloud.network.topology.AdvancedNetworkTopology) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Test(org.junit.Test)

Example 17 with VpnUser

use of com.cloud.network.VpnUser in project cloudstack by apache.

the class AddVpnUserCmd method create.

@Override
public void create() {
    Account owner = _accountService.getAccount(getEntityOwnerId());
    VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password);
    if (vpnUser == null) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add vpn user");
    }
    setEntityId(vpnUser.getId());
    setEntityUuid(vpnUser.getUuid());
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 18 with VpnUser

use of com.cloud.network.VpnUser in project cloudstack by apache.

the class AddVpnUserCmdTest method testCreateSuccess.

@Test
public void testCreateSuccess() {
    AccountService accountService = Mockito.mock(AccountService.class);
    Account account = Mockito.mock(Account.class);
    Mockito.when(accountService.getAccount(nullable(Long.class))).thenReturn(account);
    addVpnUserCmd._accountService = accountService;
    RemoteAccessVpnService ravService = Mockito.mock(RemoteAccessVpnService.class);
    VpnUser vpnUser = Mockito.mock(VpnUser.class);
    Mockito.when(ravService.addVpnUser(anyLong(), isNull(), isNull())).thenReturn(vpnUser);
    addVpnUserCmd._ravService = ravService;
    addVpnUserCmd.create();
}
Also used : Account(com.cloud.user.Account) VpnUser(com.cloud.network.VpnUser) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) AccountService(com.cloud.user.AccountService) RemoteAccessVpnService(com.cloud.network.vpn.RemoteAccessVpnService) Test(org.junit.Test)

Example 19 with VpnUser

use of com.cloud.network.VpnUser in project cloudstack by apache.

the class VpcVirtualRouterElementTest method testApplyVpnUsersException1.

@Test
public void testApplyVpnUsersException1() {
    vpcVirtualRouterElement._vpcRouterMgr = _vpcRouterMgr;
    final AdvancedNetworkTopology advancedNetworkTopology = Mockito.mock(AdvancedNetworkTopology.class);
    final BasicNetworkTopology basicNetworkTopology = Mockito.mock(BasicNetworkTopology.class);
    networkTopologyContext.setAdvancedNetworkTopology(advancedNetworkTopology);
    networkTopologyContext.setBasicNetworkTopology(basicNetworkTopology);
    networkTopologyContext.init();
    final RemoteAccessVpn remoteAccessVpn = Mockito.mock(RemoteAccessVpn.class);
    final List<VpnUser> users = new ArrayList<VpnUser>();
    when(remoteAccessVpn.getVpcId()).thenReturn(null);
    try {
        final String[] results = vpcVirtualRouterElement.applyVpnUsers(remoteAccessVpn, users);
        assertNull(results);
    } catch (final ResourceUnavailableException e) {
        fail(e.getMessage());
    }
    verify(remoteAccessVpn, times(1)).getVpcId();
}
Also used : BasicNetworkTopology(org.apache.cloudstack.network.topology.BasicNetworkTopology) VpnUser(com.cloud.network.VpnUser) ArrayList(java.util.ArrayList) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) AdvancedNetworkTopology(org.apache.cloudstack.network.topology.AdvancedNetworkTopology) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) Test(org.junit.Test)

Aggregations

VpnUser (com.cloud.network.VpnUser)19 ArrayList (java.util.ArrayList)11 Account (com.cloud.user.Account)8 Test (org.junit.Test)8 RemoteAccessVpn (com.cloud.network.RemoteAccessVpn)7 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)6 ServerApiException (com.cloud.api.ServerApiException)4 VpnUsersResponse (com.cloud.api.response.VpnUsersResponse)4 Vpc (com.cloud.network.vpc.Vpc)3 DomainRouterVO (com.cloud.vm.DomainRouterVO)3 List (java.util.List)3 AdvancedNetworkTopology (org.apache.cloudstack.network.topology.AdvancedNetworkTopology)3 BasicNetworkTopology (org.apache.cloudstack.network.topology.BasicNetworkTopology)3 ListResponse (com.cloud.api.response.ListResponse)2 Zone (com.cloud.db.model.Zone)2 DataCenterVO (com.cloud.dc.DataCenterVO)2 Domain (com.cloud.domain.Domain)2 AdvancedNetworkTopology (com.cloud.network.topology.AdvancedNetworkTopology)2 BasicNetworkTopology (com.cloud.network.topology.BasicNetworkTopology)2 RemoteAccessVpnService (com.cloud.network.vpn.RemoteAccessVpnService)2