Skip to content

Commit

Permalink
Merge pull request #67 from groldan/authservice_test_refactoring
Browse files Browse the repository at this point in the history
Refactor AuthorizationService tests
  • Loading branch information
groldan authored Jun 9, 2024
2 parents 16bd6a2 + b744c8e commit f2fdede
Show file tree
Hide file tree
Showing 11 changed files with 716 additions and 707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@
import org.geolatte.geom.MultiPolygon;
import org.geolatte.geom.codec.Wkt;
import org.geolatte.geom.jts.JTS;
import org.geoserver.acl.domain.adminrules.AdminRuleAdminService;
import org.geoserver.acl.domain.adminrules.AdminRuleAdminServiceImpl;
import org.geoserver.acl.domain.adminrules.MemoryAdminRuleRepository;
import org.geoserver.acl.domain.rules.CatalogMode;
import org.geoserver.acl.domain.rules.MemoryRuleRepository;
import org.geoserver.acl.domain.rules.Rule;
import org.geoserver.acl.domain.rules.RuleAdminService;
import org.geoserver.acl.domain.rules.RuleAdminServiceImpl;
import org.geoserver.acl.domain.rules.RuleLimits;
import org.geoserver.acl.domain.rules.SpatialFilterType;
import org.junit.jupiter.api.Test;
Expand All @@ -39,7 +33,7 @@
*
* <p>Concrete implementations must supply the required services in {@link ServiceTestBase}
*/
public class AuthorizationServiceImpl_GeomTest extends ServiceTestBase {
public abstract class AuthorizationServiceGeomTest extends AuthorizationServiceTest {
private static final String WKT_WGS84_1 =
"SRID=4326;MultiPolygon (((-1.93327272727272859 5.5959090909090925, 2.22727272727272707 5.67609090909091041, 2.00454545454545441 4.07245454545454599, -1.92436363636363761 4.54463636363636425, -1.92436363636363761 4.54463636363636425, -1.93327272727272859 5.5959090909090925)))";
private static final String WKT_WGS84_2 =
Expand All @@ -56,21 +50,6 @@ public class AuthorizationServiceImpl_GeomTest extends ServiceTestBase {
private static final String WKT_3857 =
"SRID=3857;MULTIPOLYGON(((0.0016139656066815888 -0.0006386457758059581,0.0019599705696027314 -0.0006386457758059581,0.0019599705696027314 -0.0008854090051601674,0.0016139656066815888 -0.0008854090051601674,0.0016139656066815888 -0.0006386457758059581)))";

@Override
protected RuleAdminService getRuleAdminService() {
return new RuleAdminServiceImpl(new MemoryRuleRepository());
}

@Override
protected AdminRuleAdminService getAdminRuleAdminService() {
return new AdminRuleAdminServiceImpl(new MemoryAdminRuleRepository());
}

@Override
protected AuthorizationService getAuthorizationService() {
return new AuthorizationServiceImpl(super.adminruleAdminService, super.ruleAdminService);
}

/**
* Test that the original SRID is present in the allowedArea wkt representation, when retrieving
* it from the AccessInfo object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* (c) 2023 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.acl.authorization;

import org.geoserver.acl.domain.adminrules.AdminRuleAdminService;
import org.geoserver.acl.domain.adminrules.AdminRuleAdminServiceImpl;
import org.geoserver.acl.domain.adminrules.MemoryAdminRuleRepository;
import org.geoserver.acl.domain.rules.MemoryRuleRepository;
import org.geoserver.acl.domain.rules.RuleAdminService;
import org.geoserver.acl.domain.rules.RuleAdminServiceImpl;

/**
* {@link AuthorizationService} integration/conformance test working with geometries
*
* <p>Concrete implementations must supply the required services in {@link ServiceTestBase}
*/
class AuthorizationServiceImplGeomTest extends AuthorizationServiceGeomTest {

@Override
protected RuleAdminService getRuleAdminService() {
return new RuleAdminServiceImpl(new MemoryRuleRepository());
}

@Override
protected AdminRuleAdminService getAdminRuleAdminService() {
return new AdminRuleAdminServiceImpl(new MemoryAdminRuleRepository());
}

@Override
protected AuthorizationService getAuthorizationService() {
return new AuthorizationServiceImpl(super.adminruleAdminService, super.ruleAdminService);
}
}
Loading

0 comments on commit f2fdede

Please sign in to comment.