Skip to content

Commit

Permalink
SS version changed, tests updated to work with new client.
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPCSS committed Jun 15, 2018
1 parent 23cfb57 commit 2072be3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ dependencies {
3) project dependency requires changes in settings.gradle file in this project
4) never commit build.gradle which has project dependencies active as it will break CI builds
*/
compile('com.github.symbiote-h2020:SymbIoTeSecurity:[25.7, 25.999]'){ changing = true }
compile('com.github.symbiote-h2020:SymbIoTeSecurity:[25.7.3, 25.999]'){ changing = true }
// allows to select the downloaded matching sources in IntelliJ Idea as it fails to do so automatically from jitpack repo
//compile('com.github.symbiote-h2020:SymbIoTeSecurity:[25.3, 25.999]:sources'){ changing = true }
//compile project(':SymbIoTeSecurity')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package eu.h2020.symbiote.security.unit;

import com.sun.javafx.scene.control.behavior.OptionalBoolean;
import eu.h2020.symbiote.security.AbstractADMTestSuite;
import eu.h2020.symbiote.security.commons.exceptions.custom.SecurityHandlerException;
import eu.h2020.symbiote.security.communication.payloads.AAM;
Expand All @@ -13,7 +12,6 @@
import eu.h2020.symbiote.security.repositories.entities.FailedFederatedAccessReport;
import eu.h2020.symbiote.security.services.FailedFederatedAccessReportsStatisticsService;
import eu.h2020.symbiote.security.services.helpers.ComponentSecurityHandlerProvider;
import feign.FeignException;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
Expand Down Expand Up @@ -78,8 +76,8 @@ public void setUp() throws Exception {
Set<String> set = new HashSet<>();
set.add(AP_NAME);
when(mockedComponentSecurityHandler.getSatisfiedPoliciesIdentifiers(Mockito.any(), Mockito.any())).thenReturn(set);
when(mockedComponentSecurityHandler.getFederationGroupedPlatformMisdeedsReports(Mockito.any(), Mockito.any())).thenCallRealMethod();
when(mockedComponentSecurityHandler.getOriginPlatformGroupedPlatformMisdeedsReports(Mockito.any(), Mockito.any())).thenCallRealMethod();
when(mockedComponentSecurityHandler.getFederationGroupedPlatformMisdeedsReports(Mockito.anyObject(), Mockito.anyObject())).thenCallRealMethod();
when(mockedComponentSecurityHandler.getOriginPlatformGroupedPlatformMisdeedsReports(Mockito.anyObject(), Mockito.anyObject())).thenCallRealMethod();
when(mockedComponentSecurityHandler.generateSecurityRequestUsingLocalCredentials()).thenReturn(new SecurityRequest("eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJ0ZXN0dXNlcm5hbWUiLCJzdWIiOiJ0ZXN0Y2xpZW50aWQiLCJpYXQiOjE1MDE1MDk3ODIsImV4cCI6MTUwMTUwOTg0Mn0.SGNpyl3zRA_ptRhA0lFH0o7-nhf3mpxE95ss37_jHYbCnwlRb4zDvVaYCj9DlpppU4U0y3vIPEqM44vV2UZ5Iw"));
when(mockedComponentSecurityHandler.isReceivedServiceResponseVerified(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(true);
when(mockedComponentSecurityHandler.generateServiceResponse()).thenReturn("ServiceResponce");
Expand Down Expand Up @@ -374,15 +372,15 @@ public void getFederationGroupedPlatformMisdeedsReportsSuccess() throws Security
}

@Test
public void getFederationGroupedPlatformMisdeedsReportsFailNotPassedAP() throws SecurityHandlerException {
public void getFederationGroupedPlatformMisdeedsReportsFailNotPassedAP() {

when(mockedComponentSecurityHandler.getSatisfiedPoliciesIdentifiers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
try {
componentSecurityHandlerProvider.getComponentSecurityHandler().getFederationGroupedPlatformMisdeedsReports(
Optional.of(resourcePlatformId), Optional.of(federationId));
fail();
} catch (FeignException e) {
assertEquals(HttpStatus.UNAUTHORIZED.value(), e.status());
} catch (SecurityHandlerException e) {
assertEquals(HttpStatus.UNAUTHORIZED, e.getStatusCode());
}
}

Expand All @@ -395,8 +393,8 @@ public void getFederationGroupedPlatformMisdeedsReportsFailEmptySecurityRequest(
componentSecurityHandlerProvider.getComponentSecurityHandler().getFederationGroupedPlatformMisdeedsReports(
Optional.of(resourcePlatformId), Optional.of(federationId));
fail();
} catch (FeignException e) {
assertEquals(HttpStatus.BAD_REQUEST.value(), e.status());
} catch (SecurityHandlerException e) {
assertEquals(HttpStatus.UNAUTHORIZED, e.getStatusCode());
}
}

Expand All @@ -422,15 +420,15 @@ public void getPlatformGroupedPlatformMisdeedsReportsSuccess() throws SecurityHa
}

@Test
public void getPlatformGroupedPlatformMisdeedsReportsFailNotPassedAP() throws SecurityHandlerException {
public void getPlatformGroupedPlatformMisdeedsReportsFailNotPassedAP() {

when(mockedComponentSecurityHandler.getSatisfiedPoliciesIdentifiers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
try {
componentSecurityHandlerProvider.getComponentSecurityHandler().getOriginPlatformGroupedPlatformMisdeedsReports(
Optional.of(resourcePlatformId), Optional.of(searchOriginPlatformId));
fail();
} catch (FeignException e) {
assertEquals(HttpStatus.UNAUTHORIZED.value(), e.status());
} catch (SecurityHandlerException e) {
assertEquals(HttpStatus.UNAUTHORIZED, e.getStatusCode());
}
}

Expand All @@ -443,10 +441,9 @@ public void getPlatformGroupedPlatformMisdeedsReportsFailEmptySecurityRequest()
componentSecurityHandlerProvider.getComponentSecurityHandler().getFederationGroupedPlatformMisdeedsReports(
Optional.of(resourcePlatformId), Optional.of(searchOriginPlatformId));
fail();
} catch (FeignException e) {
assertEquals(HttpStatus.BAD_REQUEST.value(), e.status());
} catch (SecurityHandlerException e) {
assertEquals(HttpStatus.UNAUTHORIZED, e.getStatusCode());
}
fail();
}


Expand Down

0 comments on commit 2072be3

Please sign in to comment.