Skip to content

Commit 8992160

Browse files
authored
Merge pull request #865 from clojars/tobias/fix-self-service-vcs-groups
2 parents 15d3b94 + bd95779 commit 8992160

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

src/clojars/verification.clj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,24 @@
161161
(doseq [group groups]
162162
(verify-group* db username group))
163163
;; We will only have two groups here, so this format string should be fine
164-
(assoc request :message (apply format "The groups '%s' & '%s' have been verified." groups)))))
164+
(assoc request
165+
:message (apply format "The groups '%s' & '%s' have been verified."
166+
(sort groups))))))
165167

166168
(defn verify-vcs-groups
167-
"Verifies the net. and com. groups for a github/gitlab organization based on url."
169+
"Verifies the io. and com. groups for a github/gitlab organization based on url."
168170
[db {:as request :keys [username url]}]
169171
(let [[provider org username-from-url] (parse-url url)
170172
candidate-groups (when org
171173
(set
172-
(for [tld ["com" "net"]]
174+
(for [tld ["com" "io"]]
173175
(str/lower-case (format "%s.%s.%s" tld provider org)))))
174176
group-verifications (into #{}
175-
(map
176-
(fn [group-name]
177-
(db/find-group-verification db group-name)))
177+
(comp
178+
(map
179+
(fn [group-name]
180+
(db/find-group-verification db group-name)))
181+
(remove nil?))
178182
candidate-groups)
179183
group-verification-names (set (map :group_name group-verifications))
180184
groups-to-verify (set/difference candidate-groups group-verifications)]

src/clojars/web/group_verification.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@
7171
[:code "https://github.com/example-org/"] " or "
7272
[:code "https://gitlab.com/example-org/"] ", you can have the groups "
7373
[:code "com.github.example-org"] " & "
74-
[:code "net.github.example-org"] " or "
74+
[:code "io.github.example-org"] " or "
7575
[:code "com.gitlab.example-org"] " & "
76-
[:code "net.gitlab.example-org"] ", respectively."]
76+
[:code "io.gitlab.example-org"] ", respectively."]
7777
[:p
7878
" You can verify ownership of the organization by creating
7979
a " [:strong "public"] " repo named "

test/clojars/integration/group_verification_test.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@
5959
(deftest user-can-verify-sub-group
6060
(help/with-TXT ["clojars dantheman"]
6161
(let [sess (-> (session)
62-
(visit "/verify/group")
63-
(within [:div.via-txt]
64-
(fill-in "Group name" "com.example")
65-
(fill-in "Domain with TXT record" "example.com")
66-
(press "Verify Group"))
67-
(follow-redirect)
68-
(within [:div.info]
69-
(has (some-text? "The group 'com.example' has been verified"))))]
62+
(visit "/verify/group")
63+
(within [:div.via-txt]
64+
(fill-in "Group name" "com.example")
65+
(fill-in "Domain with TXT record" "example.com")
66+
(press "Verify Group"))
67+
(follow-redirect)
68+
(within [:div.info]
69+
(has (some-text? "The group 'com.example' has been verified"))))]
7070
(assert-admin-email :success)
7171
(email/expect-mock-emails 1)
7272
(-> sess
7373
(within [:div.via-parent]
74-
(fill-in "Group name" "com.example.ham")
75-
(press "Verify Group"))
74+
(fill-in "Group name" "com.example.ham")
75+
(press "Verify Group"))
7676
(follow-redirect)
7777
(within [:div.info]
78-
(has (some-text? "The group 'com.example.ham' has been verified"))))
78+
(has (some-text? "The group 'com.example.ham' has been verified"))))
7979
(assert-admin-email :success))))
8080

8181
(deftest user-cannot-verify-subgroup-with-non-verified-parent
@@ -99,7 +99,7 @@
9999
(press "Verify Groups"))
100100
(follow-redirect)
101101
(within [:div.info]
102-
(has (some-text? "The groups 'com.github.example' & 'net.github.example' have been verified"))))
102+
(has (some-text? "The groups 'com.github.example' & 'io.github.example' have been verified"))))
103103
(assert-admin-email :success)))
104104

105105
(deftest user-cannot-verify-vcs-groups-with-missing-repo

test/clojars/unit/verification_test.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,18 +180,18 @@
180180

181181
(deftest verify-vcs-groups-with-already-verified-groups
182182
(db/verify-group! help/*db* "dantheman" "com.github.foo")
183-
(db/verify-group! help/*db* "dantheman" "net.github.foo")
183+
(db/verify-group! help/*db* "dantheman" "io.github.foo")
184184
(is (match?
185185
{:error (format "Groups already verified by user 'dantheman' on %s."
186186
(common/format-date (Date.)))}
187187
(nut/verify-vcs-groups help/*db* {:url "https://github.com/foo/clojars-dantheman"
188188
:username "dantheman"}))))
189189

190190
(deftest verify-vcs-groups-with-non-existent-repo
191-
(doseq [responders [(constantly {:status 404})
192-
(constantly {:status 302})
193-
(fn [& _] (throw (ex-info "BOOM" {})))]]
194-
(with-redefs [http/head responders]
191+
(doseq [responder [(constantly {:status 404})
192+
(constantly {:status 302})
193+
(fn [& _] (throw (ex-info "BOOM" {})))]]
194+
(with-redefs [http/head responder]
195195
(is (match?
196196
{:error "The verification repo does not exist."}
197197
(nut/verify-vcs-groups help/*db* {:url "https://github.com/foo/clojars-dantheman"
@@ -200,6 +200,6 @@
200200
(deftest verify-vcs-groups-when-the-repo-exists
201201
(with-redefs [http/head (constantly {:status 200})]
202202
(is (match?
203-
{:message "The groups 'com.github.foo' & 'net.github.foo' have been verified."}
203+
{:message "The groups 'com.github.foo' & 'io.github.foo' have been verified."}
204204
(nut/verify-vcs-groups help/*db* {:url "https://github.com/foo/clojars-dantheman"
205205
:username "dantheman"})))))

0 commit comments

Comments
 (0)