|
10 | 10 | [clojars.file-utils :as fu] |
11 | 11 | [clojars.http-utils :refer [clear-sessions!]] |
12 | 12 | [clojars.integration.steps :refer [create-deploy-token login-as register-as]] |
| 13 | + [clojars.routes.repo :as repo] |
13 | 14 | [clojars.s3 :as s3] |
14 | 15 | [clojars.test-helper :as help] |
15 | 16 | [clojars.web.common :as common] |
|
582 | 583 | ;; This test throws on failure, so we have this assertion to satisfy kaocha |
583 | 584 | (is true)) |
584 | 585 |
|
| 586 | +(deftest new-project-must-include-license |
| 587 | + (-> (session (help/app)) |
| 588 | + (register-as "dantheman" "test@example.org" "password")) |
| 589 | + (let [token (create-deploy-token (session (help/app)) "dantheman" "password" "testing")] |
| 590 | + (is (thrown-with-msg? |
| 591 | + DeploymentException |
| 592 | + #"Forbidden - the POM file does not include a license" |
| 593 | + (deploy |
| 594 | + {:coordinates '[org.clojars.dantheman/test "0.0.1"] |
| 595 | + :jar-file (io/file (io/resource "test.jar")) |
| 596 | + :pom-file (io/file (io/resource "test-0.0.1/test-no-license.pom")) |
| 597 | + :password token}))) |
| 598 | + |
| 599 | + (help/match-audit {:username "dantheman"} |
| 600 | + {:user "dantheman" |
| 601 | + :group_name "org.clojars.dantheman" |
| 602 | + :jar_name "test" |
| 603 | + :version "0.0.1" |
| 604 | + :message "the POM file does not include a license. See https://bit.ly/3PQunZU" |
| 605 | + :tag "missing-license"}))) |
| 606 | + |
| 607 | +(deftest existing-project-with-no-license-does-not-require-license |
| 608 | + (-> (session (help/app)) |
| 609 | + (register-as "dantheman" "test@example.org" "password")) |
| 610 | + (let [token (create-deploy-token (session (help/app)) "dantheman" "password" "testing")] |
| 611 | + ;; Deploy a version with no license with license check disabled so we can |
| 612 | + ;; get this project in a legacy state |
| 613 | + (with-redefs [repo/validate-pom-license (constantly true)] |
| 614 | + (deploy |
| 615 | + {:coordinates '[org.clojars.dantheman/test "0.0.1"] |
| 616 | + :jar-file (io/file (io/resource "test.jar")) |
| 617 | + :pom-file (io/file (io/resource "test-0.0.1/test-no-license.pom")) |
| 618 | + :password token})) |
| 619 | + |
| 620 | + ;; Deploy a new version that doesn't have a license |
| 621 | + (deploy |
| 622 | + {:coordinates '[org.clojars.dantheman/test "0.0.2"] |
| 623 | + :jar-file (io/file (io/resource "test.jar")) |
| 624 | + :pom-file (help/rewrite-pom (io/file (io/resource "test-0.0.1/test-no-license.pom")) |
| 625 | + {:version "0.0.2"}) |
| 626 | + :password token}) |
| 627 | + |
| 628 | + (help/match-audit {:username "dantheman"} |
| 629 | + {:user "dantheman" |
| 630 | + :group_name "org.clojars.dantheman" |
| 631 | + :jar_name "test" |
| 632 | + :version "0.0.2" |
| 633 | + :tag "deployed"}))) |
| 634 | + |
| 635 | +(deftest project-that-had-license-for-most-recent-release-must-provide-license |
| 636 | + (-> (session (help/app)) |
| 637 | + (register-as "dantheman" "test@example.org" "password")) |
| 638 | + (let [token (create-deploy-token (session (help/app)) "dantheman" "password" "testing")] |
| 639 | + ;; Deploy a version with a license |
| 640 | + (deploy |
| 641 | + {:coordinates '[org.clojars.dantheman/test "0.0.1"] |
| 642 | + :jar-file (io/file (io/resource "test.jar")) |
| 643 | + :pom-file (io/file (io/resource "test-0.0.1/test.pom")) |
| 644 | + :password token}) |
| 645 | + |
| 646 | + ;; Deploy a new version that doesn't have a license |
| 647 | + (is (thrown-with-msg? |
| 648 | + DeploymentException |
| 649 | + #"Forbidden - the POM file does not include a license" |
| 650 | + (deploy |
| 651 | + {:coordinates '[org.clojars.dantheman/test "0.0.2"] |
| 652 | + :jar-file (io/file (io/resource "test.jar")) |
| 653 | + :pom-file (help/rewrite-pom (io/file (io/resource "test-0.0.1/test-no-license.pom")) |
| 654 | + {:version "0.0.2"}) |
| 655 | + :password token}))) |
| 656 | + |
| 657 | + (help/match-audit {:username "dantheman"} |
| 658 | + {:user "dantheman" |
| 659 | + :group_name "org.clojars.dantheman" |
| 660 | + :jar_name "test" |
| 661 | + :version "0.0.2" |
| 662 | + :message "the POM file does not include a license. See https://bit.ly/3PQunZU" |
| 663 | + :tag "missing-license"}))) |
| 664 | + |
| 665 | + |
585 | 666 | (deftest user-can-deploy-new-version-in-same-session |
586 | 667 | (-> (session (help/app)) |
587 | 668 | (register-as "dantheman" "test@example.org" "password")) |
|
0 commit comments