Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new endpoints that allow to add/update/edit project with dependency network #2615

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hoangnt2
Copy link
Contributor

Create new endpoints that allow to add/update/edit project with dependency network

I have split this PR to separate commits, that will make it easier for reviewers to review. (Will squash commits after review successfully if needed)

This PR contains 6 new endpoints:

  1. Get linked releases in dependency network of a project
  2. Get linked releases of a release
  3. Get linked releases from sub projects of a project
  4. Compare project network (relationship in project network) with default network (relationship between release in release table)
  5. Check cyclic links between releases
  6. Duplicate project with network

Pre-condition:

Turn on feature by adding this property into /etc/sw360/sw360.properties: enable.flexible.project.release.relationship=true

Create a new project with dependency network:

{
    "name": "Test_PR",
    "dependencyNetwork": [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": []
                }
            ]
        }
    ]
}

How To Test?

1. Get linked releases in dependency network of a project**

[
    {
        "releaseId": "${release_id_1_in_sw360}",
        "releaseName": "${release_1_name}",
        "releaseVersion": "${release_1_version}",
        "componentId": "${release_1_component_id}",
        "releaseRelationship": "CONTAINED",
        "mainlineState": "OPEN",
        "comment": "",
        "releaseLink": [
            {
                "releaseId": "${release_id_2_in_sw360}",
                "releaseName": "${release_2_name}",
                "releaseVersion": "${release_2_version}",
                "componentId": "${release_2_component_id}",
                "releaseRelationship": "OPTIONAL",
                "mainlineState": "MAINLINE",
                "comment": "",
                "releaseLink": []
            }
        ]
    }
]

2. Get linked releases of a release

{
    "_embedded": {
        "sw360:releaseLinks": [
            {
                "id": "${linked_release_id}",
                "name": "${linked_release_name}",
                "version": "${linked_release_version}",
                "releaseRelationship": "CONTAINED",
                "clearingState": "NEW_CLEARING",
                "licenseIds": [],
                "accessible": true,
                "componentId": "${linked_release_component_id}"
            }
        ]
    },
    "_links": {
        "curies": [
            {
                "href": "http://localhost:8080/resource/docs/{rel}.html",
                "name": "sw360",
                "templated": true
            }
        ]
    }
}

3. Get linked releases from sub projects of a project

Step 1: Create a parent project of create Test_PR (in pre-condition):

{
    "name": "Test_PR_Parent_Project",
    "linkedProjects": {
        "{created_test_project_id}": {
            "projectRelationship": "CONTAINED",
            "enableSvm": true
        }
    }
}

Step 2: Get linked releases of sub projects (Test_PR) from parent project (Test_PR_Parent_Project):

{
    "_embedded": {
        "sw360:releases": [
            {
                "id": "${release_id_1_in_sw360}",
                "cpeid": "",
                "name": "${release_name}",
                "version": "${release_version}",
                "releaseDate": "",
                "sourceCodeDownloadurl": "",
                "binaryDownloadurl": "",
                "mainlineState": "OPEN",
                "clearingState": "NEW_CLEARING",
                "externalToolProcesses": [],
                "_links": {
                    "sw360:component": {
                        "href": "http://localhost:8080/resource/api/components/${release_component_id}"
                    },
                    "self": {
                        "href": "http://localhost:8080/resource/api/releases/${release_id_1_in_sw360}"
                    }
                }
            }
        ]
    },
    "_links": {
        "curies": [
            {
                "href": "http://localhost:8080/resource/docs/{rel}.html",
                "name": "sw360",
                "templated": true
            }
        ]
    }
}

4. Compare project network (relationship in project network) with default network (relationship between release in release table)

 [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": []
                }
            ]
        }
    ]
  • Expected output:
 [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "isDiff": false,
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": [],
                    "isDiff": true,
                }
            ]
        }
    ]

5. Check cyclic links between releases

{
    "linkedToReleases": ["{release_id_1}"],//replace by release id in sw360
    "linkedReleases": ["{release_id_2}"] //replace by release id in sw360
}
  • Example response format:
[
    {
        "message": "m (1) -> m (1)",
        "status": 409
    },
    {
        "message": "There are no cyclic link between 9649fd4f4c7b45849c40aad08f1a625a and 0a4d467b19884d79b53251646c6e7393",
        "status": 200
    }
]

6. Duplicate project with network:

{
    "name": "Test_PR_Duplicate"
}
  • Expected: Dependency network is copied successfully into duplicated project
{
    "name": "Test_PR_Duplicate",
    "createdOn": "2024-09-13",
    "businessUnit": "DEPARTMENT",
    "state": "ACTIVE",
    "clearingState": "OPEN",
    "securityResponsibles": [],
    "enableSvm": false,
    "considerReleasesFromExternalList": false,
    "enableVulnerabilitiesDisplay": false,
    "dependencyNetwork": [
        {
            "releaseId": "${release_id_1_in_sw360}",
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": "",
            "createOn": "2024-09-13",
            "createBy": "admin@sw360.org",
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}",
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "createOn": "2024-09-13",
                    "createBy": "admin@sw360.org",
                    "releaseLink": []
                }
            ]
        }
    ],
    "projectType": "PRODUCT",
    "visibility": "EVERYONE",
    "_links": {
        "self": {
            "href": "http://localhost:8080/resource/api/projects/4d13f3f5ec1e49fca4986ebbf5e4f891"
        }
    },
    "_embedded": {
        "createdBy": {
            "email": "user@sw360.org",
            "wantsMailNotification": false,
            "deactivated": false,
            "_links": {
                "self": {
                    "href": "http://localhost:8080/resource/api/users/byid/sw360-user"
                }
            }
        }
    }
}

@hoangnt2 hoangnt2 added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for REST New-UI Level for the API and UI level changes for the new-ui labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review needs general test This is general testing, meaning that there is no org specific issue to check for New-UI Level for the API and UI level changes for the new-ui REST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant