You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@creadur.apache.org by "Claudenw (via GitHub)" <gi...@apache.org> on 2024/12/10 17:29:54 UTC
[PR] Fixes to correctly detect additional valid licenses [creadur-rat]
Claudenw opened a new pull request, #413:
URL: https://github.com/apache/creadur-rat/pull/413
No ticket was opened for this change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2538275853
If I have a look at the log of the integration test I see:
```
[WARNING] Duplicate LicenseFamily category: AL (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: BSD-3 (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: CDDL1 (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: GEN (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: GPL (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: MIT (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: OASIS (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: W3C (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: W3CD (action: IGNORE)
```
could this be the cause for not recognizing GPL but labeling it UNKNOWN?
(apache-rat-plugin/target/invoker/RAT-469/build.log)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1912464038
##########
apache-rat-core/src/test/java/org/apache/rat/analysis/PolicyTest.java:
##########
@@ -0,0 +1,171 @@
+///*
Review Comment:
I reworked the tests to ensure that they are still passing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2541462533
> > Should we replace all comments in the AbstractRatMojo as
> > "@deprecated Use ." seems to be wrong as the configuration options appear directly under configuration, which is the standard element in Maven plugin configuration.
>
> I think we need to step through each of them and make a decision. "" is not always wrong but there are better solutions for most entries.
>
> I think this falls under the documentation verification step that we should get to in mid Jan.
I changed the default text in ef5c93bcc36d5f1e243179a283aad0fce13705e4
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1888775318
##########
apache-rat-core/src/test/java/org/apache/rat/license/LicenseSetFactoryTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * 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.rat.license;
+
+import java.util.SortedSet;
+import org.apache.rat.Defaults;
+import org.apache.rat.analysis.UnknownLicense;
+import org.apache.rat.testhelpers.TestingLicense;
+import org.apache.rat.testhelpers.TestingMatcher;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class LicenseSetFactoryTest {
+
+ /**
+ * This is the number of accepted licenses in the default license file :
+ * /org/apache/rat/default.xml
+ */
+ private static final int NUMBER_OF_DEFAULT_ACCEPTED_LICENSES = 7;
+
+ private static final ILicenseFamily[] APPROVED_FAMILIES = { //
+ makeFamily("AL", "Apache License Version 2.0"),
+ makeFamily("BSD-3", "BSD 3 clause"),
+ makeFamily("CDDL1", "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0"),
+ makeFamily("MIT", "The MIT License"),
+ makeFamily("OASIS", "OASIS Open License"),
+ makeFamily("W3CD", "W3C Document Copyright"),
+ makeFamily("W3C", "W3C Software Copyright"),};
+
+ private Defaults defaults;
+ private LicenseSetFactory licenseSetFactory;
+
+ @BeforeEach
+ public void setUp() {
+ defaults = Defaults.builder().build();
+ licenseSetFactory = defaults.getLicenseSetFactory();
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size()).isEqualTo(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES);
+ }
+
+ private static ILicenseFamily makeFamily(String category, String name) {
+ return ILicenseFamily.builder().setLicenseFamilyCategory(category).setLicenseFamilyName(name).build();
+ }
+
+ private SortedSet<ILicenseFamily> getUnapprovedLicenseFamilies() {
+ SortedSet<ILicenseFamily> unapproved = defaults.getLicenseSetFactory().getLicenseFamilies(LicenseSetFactory.LicenseFilter.ALL);
+ for (ILicenseFamily family : APPROVED_FAMILIES) {
+ unapproved.remove(family);
+ }
+ return unapproved;
+ }
+
+ @Test
+ void testDefaultApprovedLicenses() {
+ assertThat(APPROVED_FAMILIES.length).as("Approved license count mismatch").isEqualTo(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES);
+ for (ILicenseFamily family : APPROVED_FAMILIES) {
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not approve family " + family)
+ .isTrue();
+ }
+ }
+
+ @Test
+ void testDefaultUnApprovedLicenses() {
+ SortedSet<ILicenseFamily> unapproved = getUnapprovedLicenseFamilies();
+
+ for (ILicenseFamily family : unapproved) {
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find unapproved family " + family)
+ .isFalse();
+ }
+ }
+
+ @Test
+ public void testUnknownFamily() {
+ ILicenseFamily family = makeFamily("?????", "Unknown document");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find unapproved family " + family)
+ .isFalse();
+
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(UnknownLicense.INSTANCE))
+ .as("Did not find UnknownLicense.INSTANCE")
+ .isFalse();
+ }
+
+ @Test
+ void testLicenseCategoryManipulation() {
+ ILicenseFamily family = makeFamily("test", "Testing License Family");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved family " + family)
+ .isFalse();
+
+ licenseSetFactory.approveLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved family " + family)
+ .isTrue();
+
+ licenseSetFactory.removeLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved family " + family)
+ .isFalse();
+
+ }
+
+ @Test
+ void testAddNewApprovedLicenseNoDefaults() {
+ licenseSetFactory = new LicenseSetFactory();
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size())
+ .isEqualTo(0);
+
+ ILicenseFamily family = makeFamily("test", "Testing License Family");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did found unapproved family " + family)
+ .isFalse();
+
+ licenseSetFactory.addLicense(license);
+ licenseSetFactory.approveLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size())
+ .isEqualTo(1);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved family " + family)
+ .isTrue();
+ }
+
+ @Test
+ void testLicenseIDManipulation() {
+ String licenseId = "customId";
+ ILicenseFamily family = getUnapprovedLicenseFamilies().first();
+ TestingLicense license = new TestingLicense(licenseId, new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved id " + licenseId)
+ .isFalse();
+
+ licenseSetFactory.approveLicenseId(licenseId);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved id " + licenseId)
+ .isTrue();
+
+ licenseSetFactory.removeLicenseId(licenseId);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved id " + licenseId)
+ .isFalse();
+
+ }
+
+// @Test
+// public void testNonStandardDocumentsDoNotFailLicenseTests() {
Review Comment:
Should these test cases be added somewhere else or just remove them? Above tests test on a per license family-base and not on a document (type) basis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1894438948
##########
apache-rat-core/src/test/java/org/apache/rat/analysis/PolicyTest.java:
##########
@@ -0,0 +1,171 @@
+///*
Review Comment:
@Claudenw ping
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2541221825
In this case "IGNORE" is the action taken. It is configurable in software
but not config.
On Thu 12 Dec 2024, 14:30 P. Ottlinger, ***@***.***> wrote:
> First GPL should be recognized as a license FAMILY it is in the
> default.xml GPL1, GPL2, and GPL3 should be recognised as license IDs also
> in the default.xml
>
> [WARNING] Duplicate LicenseFamily category: W3C (action: IGNORE)
> [WARNING] Duplicate LicenseFamily category: W3CD (action: IGNORE)
>
> This indicates that at least 2 configurations were read and that the
> LicenseFamilies were defined in both. I don't see how this happens but the
> warning is there so that if you accidentally overwrite an existing license
> you get warned.
>
> Just wanted to make sure that the IGNORE does not mean that any such
> license will be ignored.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/creadur-rat/pull/413#issuecomment-2539115908>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AASTVHRK6X52X3H7F6TT5YD2FGMZ3AVCNFSM6AAAAABTLVX2FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZZGEYTKOJQHA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1894583981
##########
apache-rat-core/src/test/java/org/apache/rat/analysis/PolicyTest.java:
##########
@@ -0,0 +1,171 @@
+///*
Review Comment:
I will have to make another pass to verify the tests are covered in more reasonable places.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1885800808
##########
apache-rat-core/src/test/java/org/apache/rat/analysis/PolicyTest.java:
##########
@@ -0,0 +1,171 @@
+///*
Review Comment:
Shall we remove this or enable it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2539149613
I merged in master and HeaderCheckWorkerTest is broken.
@Claudenw Is it intended that the license family "unknown" is approved by default?
```
+++ b/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
@@ -43,8 +43,8 @@ public class HeaderCheckWorkerTest {
ILicense matcher = new TestingLicense("test", "test");
HeaderCheckWorker worker = new HeaderCheckWorker(new TestingMatcher(), new StringReader(""), Lists.list(matcher), subject);
worker.read();
- assertThat(subject.getMetaData().unapprovedLicenses().count()).isEqualTo(1);
- assertThat(subject.getMetaData().unapprovedLicenses().collect(Collectors.toList()).get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
+ assertThat(subject.getMetaData().approvedLicenses().count()).isEqualTo(1);
+ assertThat(subject.getMetaData().approvedLicenses().collect(Collectors.toList()).get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw merged PR #413:
URL: https://github.com/apache/creadur-rat/pull/413
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2541226854
Nope. Unknown lice se can not be approved unless specifically added by the
user. I will check on this this weekend
On Thu 12 Dec 2024, 14:44 P. Ottlinger, ***@***.***> wrote:
> I merged in master and HeaderCheckWorkerTest is broken.
>
> @Claudenw <https://github.com/Claudenw> Is it intended that the license
> family "unknown" is approved by default?
>
> +++ b/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
> @@ -43,8 +43,8 @@ public class HeaderCheckWorkerTest {
> ILicense matcher = new TestingLicense("test", "test");
> HeaderCheckWorker worker = new HeaderCheckWorker(new TestingMatcher(), new StringReader(""), Lists.list(matcher), subject);
> worker.read();
> - assertThat(subject.getMetaData().unapprovedLicenses().count()).isEqualTo(1);
> - assertThat(subject.getMetaData().unapprovedLicenses().collect(Collectors.toList()).get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
> + assertThat(subject.getMetaData().approvedLicenses().count()).isEqualTo(1);
> + assertThat(subject.getMetaData().approvedLicenses().collect(Collectors.toList()).get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
> }
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/creadur-rat/pull/413#issuecomment-2539149613>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AASTVHQVV46VIDZC2AXX3Y32FGOK7AVCNFSM6AAAAABTLVX2FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZZGE2DSNRRGM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2535964591
Thanks for raising this issue!
Should we replace all comments in the Mojo as
"@deprecated Use <config>." seems to be wrong as the configuration options appear directly under configuration, which is the standard element in Maven plugin configuration.
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2536374764
@Claudenw I added GPL as a valid license - I always thought this could be configured and I do not need to add a new defaults.xml file in my project.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2536271103
@Claudenw apart from the fact the IT needs to be adapted once the patch is applied I wonder why GPL is not yet recognized and logged explicitly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1888775318
##########
apache-rat-core/src/test/java/org/apache/rat/license/LicenseSetFactoryTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * 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.rat.license;
+
+import java.util.SortedSet;
+import org.apache.rat.Defaults;
+import org.apache.rat.analysis.UnknownLicense;
+import org.apache.rat.testhelpers.TestingLicense;
+import org.apache.rat.testhelpers.TestingMatcher;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class LicenseSetFactoryTest {
+
+ /**
+ * This is the number of accepted licenses in the default license file :
+ * /org/apache/rat/default.xml
+ */
+ private static final int NUMBER_OF_DEFAULT_ACCEPTED_LICENSES = 7;
+
+ private static final ILicenseFamily[] APPROVED_FAMILIES = { //
+ makeFamily("AL", "Apache License Version 2.0"),
+ makeFamily("BSD-3", "BSD 3 clause"),
+ makeFamily("CDDL1", "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0"),
+ makeFamily("MIT", "The MIT License"),
+ makeFamily("OASIS", "OASIS Open License"),
+ makeFamily("W3CD", "W3C Document Copyright"),
+ makeFamily("W3C", "W3C Software Copyright"),};
+
+ private Defaults defaults;
+ private LicenseSetFactory licenseSetFactory;
+
+ @BeforeEach
+ public void setUp() {
+ defaults = Defaults.builder().build();
+ licenseSetFactory = defaults.getLicenseSetFactory();
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size()).isEqualTo(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES);
+ }
+
+ private static ILicenseFamily makeFamily(String category, String name) {
+ return ILicenseFamily.builder().setLicenseFamilyCategory(category).setLicenseFamilyName(name).build();
+ }
+
+ private SortedSet<ILicenseFamily> getUnapprovedLicenseFamilies() {
+ SortedSet<ILicenseFamily> unapproved = defaults.getLicenseSetFactory().getLicenseFamilies(LicenseSetFactory.LicenseFilter.ALL);
+ for (ILicenseFamily family : APPROVED_FAMILIES) {
+ unapproved.remove(family);
+ }
+ return unapproved;
+ }
+
+ @Test
+ void testDefaultApprovedLicenses() {
+ assertThat(APPROVED_FAMILIES.length).as("Approved license count mismatch").isEqualTo(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES);
+ for (ILicenseFamily family : APPROVED_FAMILIES) {
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not approve family " + family)
+ .isTrue();
+ }
+ }
+
+ @Test
+ void testDefaultUnApprovedLicenses() {
+ SortedSet<ILicenseFamily> unapproved = getUnapprovedLicenseFamilies();
+
+ for (ILicenseFamily family : unapproved) {
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find unapproved family " + family)
+ .isFalse();
+ }
+ }
+
+ @Test
+ public void testUnknownFamily() {
+ ILicenseFamily family = makeFamily("?????", "Unknown document");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find unapproved family " + family)
+ .isFalse();
+
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(UnknownLicense.INSTANCE))
+ .as("Did not find UnknownLicense.INSTANCE")
+ .isFalse();
+ }
+
+ @Test
+ void testLicenseCategoryManipulation() {
+ ILicenseFamily family = makeFamily("test", "Testing License Family");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved family " + family)
+ .isFalse();
+
+ licenseSetFactory.approveLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved family " + family)
+ .isTrue();
+
+ licenseSetFactory.removeLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved family " + family)
+ .isFalse();
+
+ }
+
+ @Test
+ void testAddNewApprovedLicenseNoDefaults() {
+ licenseSetFactory = new LicenseSetFactory();
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size())
+ .isEqualTo(0);
+
+ ILicenseFamily family = makeFamily("test", "Testing License Family");
+ TestingLicense license = new TestingLicense(family.getFamilyCategory().trim(), new TestingMatcher(), family);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did found unapproved family " + family)
+ .isFalse();
+
+ licenseSetFactory.addLicense(license);
+ licenseSetFactory.approveLicenseCategory(family.getFamilyCategory());
+ assertThat(licenseSetFactory.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED).size())
+ .isEqualTo(1);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved family " + family)
+ .isTrue();
+ }
+
+ @Test
+ void testLicenseIDManipulation() {
+ String licenseId = "customId";
+ ILicenseFamily family = getUnapprovedLicenseFamilies().first();
+ TestingLicense license = new TestingLicense(licenseId, new TestingMatcher(), family);
+
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved id " + licenseId)
+ .isFalse();
+
+ licenseSetFactory.approveLicenseId(licenseId);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Did not find approved id " + licenseId)
+ .isTrue();
+
+ licenseSetFactory.removeLicenseId(licenseId);
+ assertThat(licenseSetFactory.getApprovedLicensePredicate().test(license))
+ .as("Found unapproved id " + licenseId)
+ .isFalse();
+
+ }
+
+// @Test
+// public void testNonStandardDocumentsDoNotFailLicenseTests() {
Review Comment:
Should these test cases be added somewhere else or just remove them?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1912490607
##########
apache-rat-core/src/main/java/org/apache/rat/license/LicenseSetFactory.java:
##########
@@ -338,7 +344,7 @@ public SortedSet<String> getLicenseCategories(final LicenseFilter filter) {
return result;
case APPROVED:
approvedLicenseCategories.stream().filter(s -> !removedLicenseCategories.contains(s)).forEach(result::add);
- licenses.stream().filter(approved).forEach(l -> result.add(l.getLicenseFamily().getFamilyCategory()));
+ //licenses.stream().filter(approved).forEach(l -> result.add(l.getLicenseFamily().getFamilyCategory()));
Review Comment:
I removed the piece of code via [16a2319](https://github.com/apache/creadur-rat/pull/413/commits/16a2319181f4a60f414f04e42ab1932ec94207f6)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2585932506
GPL content is still recognised as UNKNOWN even if configured as an approvedLicense.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2536285013
Gpl is not allowed at apache. So you have to add to the defaults
On Wed 11 Dec 2024, 15:12 P. Ottlinger, ***@***.***> wrote:
> @Claudenw <https://github.com/Claudenw> apart from the fact the IT needs
> to be adapted once the patch is applied I wonder why GPL is not yet
> recognized and logged explicitly.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/apache/creadur-rat/pull/413#issuecomment-2536271103>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AASTVHTSDPYQ6L3UFPJJEC32FBI4BAVCNFSM6AAAAABTLVX2FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZWGI3TCMJQGM>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2536487348
I think I mistyped. I said "So you have to add to the defaults" when what I meant was you need to add GPL-1, GPL-2, or GPL-3 as an approved license ID or add GPL as an approved license family. The licenses are defined but they are not listed approved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1885800808
##########
apache-rat-core/src/test/java/org/apache/rat/analysis/PolicyTest.java:
##########
@@ -0,0 +1,171 @@
+///*
Review Comment:
Shall we remove this or enable it as Policy was removed?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on code in PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#discussion_r1912478436
##########
apache-rat-core/src/main/java/org/apache/rat/license/LicenseSetFactory.java:
##########
@@ -338,7 +344,7 @@ public SortedSet<String> getLicenseCategories(final LicenseFilter filter) {
return result;
case APPROVED:
approvedLicenseCategories.stream().filter(s -> !removedLicenseCategories.contains(s)).forEach(result::add);
- licenses.stream().filter(approved).forEach(l -> result.add(l.getLicenseFamily().getFamilyCategory()));
+ //licenses.stream().filter(approved).forEach(l -> result.add(l.getLicenseFamily().getFamilyCategory()));
Review Comment:
@Claudenw is this a leftover or a TODO ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2536492677
> Should we replace all comments in the AbstractRatMojo as
> "@deprecated Use <config>." seems to be wrong as the configuration options appear directly under configuration, which is the standard element in Maven plugin configuration.
I think we need to step through each of them and make a decision. "<config>" is not always wrong but there are better solutions for most entries.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "Claudenw (via GitHub)" <gi...@apache.org>.
Claudenw commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2539097080
First GPL should be recognized as a license FAMILY it is in the default.xml
GPL-1, GPL-2, and GPL-3 should be recognised as license IDs also in the default.xml
```
[WARNING] Duplicate LicenseFamily category: W3C (action: IGNORE)
[WARNING] Duplicate LicenseFamily category: W3CD (action: IGNORE)
```
This indicates that at least 2 configurations were read and that the LicenseFamilies were defined in both. I don't see how this happens but the warning is there so that if you accidentally overwrite an existing license you get warned.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RAT-469: Fixes to correctly detect additional valid licenses [creadur-rat]
Posted by "ottlinger (via GitHub)" <gi...@apache.org>.
ottlinger commented on PR #413:
URL: https://github.com/apache/creadur-rat/pull/413#issuecomment-2539115908
> First GPL should be recognized as a license FAMILY it is in the default.xml GPL1, GPL2, and GPL3 should be recognised as license IDs also in the default.xml
>
> ```
> [WARNING] Duplicate LicenseFamily category: W3C (action: IGNORE)
> [WARNING] Duplicate LicenseFamily category: W3CD (action: IGNORE)
> ```
>
> This indicates that at least 2 configurations were read and that the LicenseFamilies were defined in both. I don't see how this happens but the warning is there so that if you accidentally overwrite an existing license you get warned.
Just wanted to make sure that the IGNORE does not mean that any such license will be ignored.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@creadur.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org