Skip to content

Commit

Permalink
Merging build #233
Browse files Browse the repository at this point in the history
  • Loading branch information
axiomatics-andreas authored Jul 5, 2024
2 parents b23521b + 57c56dd commit 0e8071e
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 29 deletions.
8 changes: 5 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ plugins {
envAccessKey.equals("Put the key id provided by Axiomatics here!") ||
envSecretKey.equals("Put the secret key provided by Axiomatics here!")
) {
throw new GradleException("Credential to Axiomatics repository not set. Please set credentials provided by Axiomatics in file gradle.properties or as environment variables. " +
"If you have not received the credentials, contact your Axiomatics support")
def msg = "Credential to Axiomatics repository not set. Please set credentials provided by Axiomatics in file gradle.properties or as environment variables. " +
"If you have not received the credentials, contact your Axiomatics support"
println msg
throw new GradleException(msg)
}

repositories {
Expand All @@ -37,6 +39,7 @@ repositories {
secretKey = envSecretKey
}
}
mavenCentral()
} //!offline
}
dependencies {
Expand All @@ -48,5 +51,4 @@ dependencies {
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.3"
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
implementation 'org.ajoberstar.grgit:grgit-core:5.2.0'

}
10 changes: 9 additions & 1 deletion buildSrc/src/main/groovy/AlfaPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import tasks.AdmPushTask
import tasks.AlfaCompilationTask
import org.gradle.jvm.toolchain.JavaLanguageVersion

class AlfaPlugin implements Plugin<Project> {

Expand All @@ -24,6 +25,11 @@ class AlfaPlugin implements Plugin<Project> {
project.logger.info("Access key id found ${accessKey}")
project.extensions.create('alfa', AlfaExtension, project)
project.plugins.apply('java')
project.java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
project.plugins.apply('distribution')
project.getPluginManager().apply("com.palantir.docker")
project.tasks.register("buildAuthzDomain", BuildAuthZDomainTask.class) {
Expand Down Expand Up @@ -76,6 +82,7 @@ class AlfaPlugin implements Plugin<Project> {
logger.info("Environment is ${environment}")
workingDir "src/extra"
}
useJUnitPlatform()
outputs.upToDateWhen {false}
environment "ALFA_TEST_REMOTE_MAIN_POLICY" , "${project.extensions.alfa.mainpolicy}"
testLogging {
Expand All @@ -88,7 +95,8 @@ class AlfaPlugin implements Plugin<Project> {
showCauses true
showExceptions true
showStackTraces true
showStandardStreams false

showStandardStreams logger.isDebugEnabled()
}
}
project.tasks.compileAlfa {
Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/groovy/alfa-testing-framework.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ repositories {
}
}



configurations {
domTool
alfac
Expand All @@ -50,8 +52,10 @@ configurations.all {


dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation "com.axiomatics.cr.alfa.test:alfa-test-framework:1.0.24"
testImplementation(platform("org.junit:junit-bom:5.11.0-M2"))
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
testImplementation "com.axiomatics.cr.alfa.test:alfa-test-framework:1.0.26"

domTool(group: 'com.axiomatics.domtool', name: 'domtool', version: '0.10.1')
domTool(group: 'com.axiomatics.domtool', name: 'domtool-lib', version: '0.10.1')
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 19 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
buildscript {
repositories {
def offlineLib = rootProject.projectDir.toPath().resolve("../lib").toFile()
if (offlineLib.exists()) {
println "Running in offline mode using local repository at ${offlineLib}"
maven {
url uri(offlineLib)
}
} else {
gradlePluginPortal()

} //!offline
}

}

plugins {
id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0"
}
rootProject.name = 'my-alfa-project'
14 changes: 7 additions & 7 deletions src/test/java/com/myorg/alfa/MyAttributeconnectorTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.myorg.alfa;


import com.axiomatics.cr.alfa.test.junit.AlfaTestRule;
import com.axiomatics.cr.alfa.test.junit.AlfaExtension;
import com.axiomatics.cr.alfa.test.junit.AttributeConnector;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.List;

Expand All @@ -13,12 +13,12 @@

public class MyAttributeconnectorTest {

@Rule
public AlfaTestRule rule = new AlfaTestRule();
@RegisterExtension
public AlfaExtension alfa = new AlfaExtension();

@Test
public void shouldGetRoleConsultantForCecilia() {
AttributeConnector target = rule.newAttributeTest("ourConnector");
AttributeConnector target = alfa.newAttributeTest("ourConnector");

List<String> result = target.lookup("user.role").by("user.identity", "cecilia");

Expand All @@ -27,7 +27,7 @@ public void shouldGetRoleConsultantForCecilia() {

@Test
public void shouldGetRoleManagerForMartin() {
AttributeConnector target = rule.newAttributeTest("ourConnector");
AttributeConnector target = alfa.newAttributeTest("ourConnector");

List<String> result = target.lookup("user.role").by("user.identity", "martin");

Expand Down
15 changes: 8 additions & 7 deletions src/test/java/com/myorg/alfa/MyConsultantPolicyUnitTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.myorg.alfa;

import com.axiomatics.cr.alfa.test.junit.AlfaTestRule;
import com.axiomatics.cr.alfa.test.junit.AlfaExtension;
import com.axiomatics.cr.alfa.test.junit.TestRequest;
import com.axiomatics.cr.alfa.test.junit.TestResponse;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static com.axiomatics.cr.alfa.test.junit.matchers.AlfaMatchers.permit;
import static org.hamcrest.CoreMatchers.is;
Expand All @@ -13,12 +13,13 @@

public class MyConsultantPolicyUnitTest {

@Rule
public AlfaTestRule rule = new AlfaTestRule().withMainPolicy("consultants.Main");

@RegisterExtension
public AlfaExtension alfa = new AlfaExtension().withMainPolicy("consultants.Main");

@Test
public void shouldPermitIfUserAndResourceAreInSameLocation() {
TestRequest target = rule.newTestRequest()
TestRequest target = alfa.newTestRequest()
.with("user.role", "consultant")
.with("user.location", "hawaii")
.with("resource.location", "hawaii");
Expand All @@ -30,7 +31,7 @@ public void shouldPermitIfUserAndResourceAreInSameLocation() {

@Test
public void shouldNotPermitIfUserAndResourceAreInDifferentLocation() {
TestRequest target = rule.newTestRequest()
TestRequest target = alfa.newTestRequest()
.with("user.role", "consultant")
.with("user.location", "hawaii")
.with("resource.location", "stockholm");
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/com/myorg/alfa/MySystemTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.myorg.alfa;

import com.axiomatics.cr.alfa.test.junit.AlfaTestRule;
import com.axiomatics.cr.alfa.test.junit.AlfaExtension;
import com.axiomatics.cr.alfa.test.junit.TestRequest;
import com.axiomatics.cr.alfa.test.junit.TestResponse;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static com.axiomatics.cr.alfa.test.junit.matchers.AlfaMatchers.permit;
import static com.axiomatics.cr.alfa.test.junit.matchers.AttributeAssignmentMatcher.withText;
Expand All @@ -13,12 +13,12 @@

public class MySystemTest {

@Rule
public AlfaTestRule rule = new AlfaTestRule().withAttributeConnectors();
@RegisterExtension
public AlfaExtension alfa = new AlfaExtension().withAttributeConnectors();

@Test
public void shouldGiveMartinAccessToResource1() {
TestRequest target = rule.newTestRequest()
TestRequest target = alfa.newTestRequest()
.with("user.identity", "martin")
.with("resource.identity", "1");

Expand All @@ -30,7 +30,7 @@ public void shouldGiveMartinAccessToResource1() {

@Test
public void shouldGiveCeciliaAccessToResource1() {
TestRequest target = rule.newTestRequest()
TestRequest target = alfa.newTestRequest()
.with("user.identity", "cecilia")
.with("resource.identity", "1");

Expand All @@ -42,7 +42,7 @@ public void shouldGiveCeciliaAccessToResource1() {

@Test
public void shouldNotGiveCeciliaAccessToResource2() {
TestRequest target = rule.newTestRequest()
TestRequest target = alfa.newTestRequest()
.with("user.identity", "cecilia")
.with("resource.identity", "2");

Expand Down

0 comments on commit 0e8071e

Please sign in to comment.