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

fix(package): Create package by API can't link release #2150

Merged

Conversation

tuannn2
Copy link
Contributor

@tuannn2 tuannn2 commented Oct 16, 2023

Issue: API create Package can't link the Release

Suggest Reviewer

@KoukiHama

How To Test?

  • Execute API create new Package:
$ curl 'https://sw360.org/api/packages' -i -X POST \
    -H 'Content-Type: application/hal+json' \
    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsic3czNjAtUkVTVC1BUEkiXSwidXNlcl9uYW1lIjoiYWRtaW5Ac3czNjAub3JnIiwic2NvcGUiOlsiYWxsIl0sImV4cCI6MTY5NzQ0MzY4OSwiYXV0aG9yaXRpZXMiOlsiUkVBRCIsIldSSVRFIl0sImp0aSI6IlhKQVFFQkZyeGxieFJONUFRSDU3dGtfYzJkbyIsImNsaWVudF9pZCI6InRydXN0ZWQtc3czNjAtY2xpZW50In0.ZueR84mNgqUULCYXTkFSSX4GGb01nPFcrINisAE5x8DCjdH1SQp7TeHoLmBi75QPzSBTlMCf66_1G3CVU7w_AqCV9aohl2OFELEQRHKbdI3KcRHWEBd-cW5SuLs-zcb8AmSDVju7uCEuoCluq35BgfvVI-YtlboGWkuZBW_jRSuSnFn4S0M2UyrE4g0VR-a7xmYE2TLvGW9IwWrev0vVCdDTslkXkyU098ze9JwOlLJvco5OxHNJQ4c0sozdz49iQNq1-qERu111A0pxt5AzCnr4cCsEvhO9Js_PVVpMUgTEMsRz5Yy03CgLfA9rD8t2L6azXqtKDWHftBkajMlMnA' \
    -d '{
  "name" : "angular-sanitize",
  "version" : "1.8.2",
  "packageType" : "LIBRARY",
  "purl" : "pkg:npm/[email protected]",
  "vcs" : "git+https://github.com/angular/angular.js.git",
  "homepageUrl" : "https://github.com/angular/angular-sanitize",
  "licenseIds" : [ "GPL", "MIT" ],
  "releaseId" : "98745",
  "description" : "Sanitizes a html string by stripping all potentially dangerous tokens."
}'
  • Expected response:
{
  "name" : "angular-sanitize",
  "version" : "1.8.2",
  "purl" : "pkg:npm/[email protected]",
  "packageType" : "FRAMEWORK",
  "releaseId" : "98745",
  "licenseIds" : [ "GPL", "MIT" ],
  "description" : "Sanitizes an html string by stripping all potentially dangerous tokens.",
  "homepageUrl" : "http://angularjs.org",
  "vcs" : "git+https://github.com/angular/angular.js.git",
  "_links" : {
    "self" : {
      "href" : "https://sw360.org/api/packages/122357345"
    }
  },
  "_embedded" : {
    "sw360:release" : {
      "name" : "Test Release",
      "version" : "2",
      "_links" : {
        "self" : {
          "href" : "https://sw360.org/api/releases/98745"
        }
      }
    },
    "createdBy" : {
      "email" : "[email protected]",
      "deactivated" : false,
      "_links" : {
        "self" : {
          "href" : "https://sw360.org/api/users/byid/123456789"
        }
      }
    }
  }
}

@tienlee tienlee added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for labels Oct 16, 2023
@KoukiHama KoukiHama added the REST label Oct 16, 2023
@nikkuma7
Copy link
Contributor

Hi @KoukiHama ,
Two fields are not coming in response :
1: createdOn
2: packageManager
Even though both fields are there in the Database.

image
image

@KoukiHama
Copy link
Member

@tuannn2 could you check it?

@tuannn2
Copy link
Contributor Author

tuannn2 commented Oct 19, 2023

@tuannn2 could you check it?

Yes, I will check it.

@tuannn2
Copy link
Contributor Author

tuannn2 commented Oct 19, 2023

Hi @nikkuma7, @KoukiHama
This PR only focus to issues Package link to Release. It does not affect the response of the API Create Package.
According to the original specification, the above 2 properties are not returned in response.

I think we should keep the API's current response as is.

@KoukiHama
Copy link
Member

@afsahsyeda Could you tell us what do you think this?

@afsahsyeda
Copy link
Contributor

Hi @KoukiHama, I didn't include the "package manager" field in the previous response as it is already evident from the "purl" field. Additionally, the "createdOn" field is only generated when requesting "allDetails" of a package. I believe a similar response structure is maintained for projects, components, and other entities.

@KoukiHama
Copy link
Member

KoukiHama commented Oct 19, 2023

For this PR, We can ignore these items.
1: createdOn
2: packageManager

However, lets make new issue for discussing the response about createdOn , after merge this PR.

@nikkuma7
Copy link
Contributor

As per the above comment, Test successful.

@KoukiHama KoukiHama removed the needs general test This is general testing, meaning that there is no org specific issue to check for label Oct 20, 2023
@KoukiHama
Copy link
Member

codes are good.

@KoukiHama KoukiHama added ready ready to merge and removed needs code review labels Oct 25, 2023
@ag4ums ag4ums merged commit 08aa966 into eclipse-sw360:main Oct 26, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ready to merge REST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants