You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: enforce minimum one obligation requirement for licenses (Issue fossology#136)
- Add validation to CreateLicense endpoint to reject licenses without obligations
- Add validation to UpdateLicense endpoint to prevent removing all obligations
- Add validation to ImportLicenses flow for imported licenses
- Update existing tests to include obligations
- Add new test case for license creation without obligations
- Create getTestObligation() helper function for tests
Addresses all feedback from PR fossology#191:
- Validation occurs before database transactions (not after)
- UpdateLicense endpoint now validates obligations
- All test cases updated and passing
- Clear, user-friendly error messages
Fixesfossology#136
Signed-off-by: abhayrajjais01 <abhayraj916146@gmail.com>
Copy file name to clipboardExpand all lines: tests/licenses_test.go
+47-23Lines changed: 47 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,15 @@ import (
16
16
17
17
funcTestCreateLicense(t*testing.T) {
18
18
license:= models.LicenseCreateDTO{
19
-
Shortname: "MIT1",
20
-
Fullname: "MIT License",
21
-
Text: `MIT1 License copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`,
22
-
Url: ptr("https://opensource.org/licenses/MIT"),
23
-
Notes: ptr("This license is OSI approved."),
24
-
Source: ptr("spdx"),
25
-
SpdxId: "LicenseRef-MIT1",
26
-
Risk: ptr(int64(2)),
19
+
Shortname: "MIT1",
20
+
Fullname: "MIT License",
21
+
Text: `MIT1 License copyright (c) <year> <copyright holders> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`,
0 commit comments