Skip to content

Commit

Permalink
Properly assign boolean to is_resolved #3152
Browse files Browse the repository at this point in the history
    * Add new test

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Nov 19, 2022
1 parent a410f6e commit c24c221
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/packagedcode/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def get_dependencies(pom):
if dversion == 'latest.release':
dversion = None

is_resolved = dversion and not any(c in dversion for c in '$[,]')
is_resolved = bool(dversion and not any(c in dversion for c in '$[,]'))

dqualifiers = {}
# FIXME: this is missing from the original Pom parser
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.wordnik</groupId>
<artifactId>swagger-project_2.10</artifactId>
<version>1.3.1</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>swagger-java-sample-app_2.10</artifactId>
<packaging>war</packaging>
<name>swagger-java-jaxrs-app</name>
<version>1.3.1</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppConfig>
<contextPath>/api</contextPath>
</webAppConfig>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<webDefaultXml>${project.basedir}/conf/jetty/webdefault.xml</webDefaultXml>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>8002</port>
<maxIdleTime>60000</maxIdleTime>
<confidentialPort>8443</confidentialPort>
</connector>
</connectors>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"type": "maven",
"namespace": "com.wordnik",
"name": "swagger-java-sample-app_2.10",
"version": "1.3.1",
"qualifiers": {
"type": "war"
},
"subpath": null,
"primary_language": "Java",
"description": "swagger-java-jaxrs-app",
"release_date": null,
"parties": [],
"keywords": [],
"homepage_url": null,
"download_url": null,
"size": null,
"sha1": null,
"md5": null,
"sha256": null,
"sha512": null,
"bug_tracking_url": null,
"code_view_url": null,
"vcs_url": null,
"copyright": null,
"declared_license_expression": null,
"declared_license_expression_spdx": null,
"license_detections": [],
"other_license_expression": null,
"other_license_expression_spdx": null,
"other_license_detections": [],
"extracted_license_statement": null,
"notice_text": null,
"source_packages": [
"pkg:maven/com.wordnik/[email protected]?classifier=sources"
],
"file_references": [],
"extra_data": {},
"dependencies": [
{
"purl": "pkg:maven/com.wordnik/swagger-jaxrs_2.10",
"extracted_requirement": null,
"scope": "compile",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
},
{
"purl": "pkg:maven/ch.qos.logback/logback-classic",
"extracted_requirement": "${logback-version}",
"scope": "compile",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
},
{
"purl": "pkg:maven/ch.qos.logback/logback-core",
"extracted_requirement": "${logback-version}",
"scope": "compile",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
},
{
"purl": "pkg:maven/javax.servlet/servlet-api",
"extracted_requirement": null,
"scope": "compile",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
},
{
"purl": "pkg:maven/org.scalatest/scalatest_2.10",
"extracted_requirement": null,
"scope": "test",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
},
{
"purl": "pkg:maven/junit/junit",
"extracted_requirement": null,
"scope": "test",
"is_runtime": false,
"is_optional": true,
"is_resolved": false,
"resolved_package": {},
"extra_data": {}
}
],
"repository_homepage_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/",
"repository_download_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/swagger-java-sample-app_2.10-1.3.1.war",
"api_data_url": "https://repo1.maven.org/maven2/com/wordnik/swagger-java-sample-app_2.10/1.3.1/swagger-java-sample-app_2.10-1.3.1.pom",
"datasource_id": "maven_pom",
"purl": "pkg:maven/com.wordnik/[email protected]?type=war"
}
5 changes: 5 additions & 0 deletions tests/packagedcode/test_maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ def test_package_dependency_not_missing(self):
test_file = self.get_test_loc('maven2/log4j/log4j-pom.xml')
self.check_parse_to_package(test_file, regen=REGEN_TEST_FIXTURES)

def test_package_dependency_populate_is_resolved_field(self):
test_file = self.get_test_loc('maven_misc/parse/swagger-java-sample-app_2.10-1.3.1.pom')
self.check_parse_to_package(test_file, regen=REGEN_TEST_FIXTURES)



class TestPomProperties(testcase.FileBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')
Expand Down

0 comments on commit c24c221

Please sign in to comment.