You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2019/12/11 13:38:08 UTC

[sling-org-apache-sling-committer-cli] branch master updated (75b5594 -> 59bd129)

This is an automated email from the ASF dual-hosted git repository.

radu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git.


    from 75b5594  SLING-8864 - Report authentication errors immediately without looking at the response's body
     new 3044b64  SLING-8741 - Remove separate Jira credentials
     new 59bd129  SLING-8864 - Report authentication errors immediately without looking at the response's body

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/sling/cli/impl/CredentialsService.java  |  9 ------
 .../sling/cli/impl/http/HttpClientFactory.java     |  5 ++-
 .../sling/cli/impl/CredentialsServiceTest.java     |  3 --
 .../sling/cli/impl/http/HttpClientFactoryTest.java | 30 ++++++------------
 .../org/apache/sling/cli/impl/jira/MockJira.java   |  4 +--
 .../sling/cli/impl/jira/VersionClientTest.java     |  3 +-
 .../impl/{jira => junit}/SystemPropertiesRule.java | 36 ++++++++++++----------
 .../cli/impl/nexus/RepositoryServiceTest.java      |  2 +-
 .../cli/impl/pgp/PGPSignatureValidatorTest.java    |  2 +-
 9 files changed, 35 insertions(+), 59 deletions(-)
 rename src/test/java/org/apache/sling/cli/impl/{jira => junit}/SystemPropertiesRule.java (50%)


[sling-org-apache-sling-committer-cli] 01/02: SLING-8741 - Remove separate Jira credentials

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git

commit 3044b64d0b116fc17556cb4ce6c3ff2970375658
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Wed Dec 11 14:32:45 2019 +0100

    SLING-8741 - Remove separate Jira credentials
    
    * adapted code to use only the ASF credentials when interacting
    with Jira
---
 src/main/java/org/apache/sling/cli/impl/CredentialsService.java  | 9 ---------
 .../java/org/apache/sling/cli/impl/http/HttpClientFactory.java   | 5 ++---
 .../java/org/apache/sling/cli/impl/CredentialsServiceTest.java   | 3 ---
 src/test/java/org/apache/sling/cli/impl/jira/MockJira.java       | 4 ++--
 .../java/org/apache/sling/cli/impl/jira/VersionClientTest.java   | 2 --
 5 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/src/main/java/org/apache/sling/cli/impl/CredentialsService.java b/src/main/java/org/apache/sling/cli/impl/CredentialsService.java
index 127c8fe..f869972 100644
--- a/src/main/java/org/apache/sling/cli/impl/CredentialsService.java
+++ b/src/main/java/org/apache/sling/cli/impl/CredentialsService.java
@@ -29,25 +29,16 @@ public class CredentialsService {
     private static final ValueSource ASF_USER = new ValueSource("asf.username", "ASF_USERNAME", "ASF user information");
     private static final ValueSource ASF_PWD = new ValueSource("asf.password", "ASF_PASSWORD", "ASF password");
 
-    private static final ValueSource JIRA_USER = new ValueSource("jira.username", "JIRA_USERNAME", "Jira user information");
-    private static final ValueSource JIRA_PWD = new ValueSource("jira.password", "JIRA_PASSWORD", "Jira password");
-    
     private Credentials asfCredentials;
-    private Credentials jiraCredentials;
 
     @Activate
     protected void activate() {
         asfCredentials = new Credentials(ASF_USER.getValue(), ASF_PWD.getValue());
-        jiraCredentials = new Credentials(JIRA_USER.getValue(), JIRA_PWD.getValue());
     }
     
     public Credentials getAsfCredentials() {
         return asfCredentials;
     }
-    
-    public Credentials getJiraCredentials() {
-        return jiraCredentials;
-    }
 
     static class ValueSource {
 
diff --git a/src/main/java/org/apache/sling/cli/impl/http/HttpClientFactory.java b/src/main/java/org/apache/sling/cli/impl/http/HttpClientFactory.java
index 4fbc065..3040429 100644
--- a/src/main/java/org/apache/sling/cli/impl/http/HttpClientFactory.java
+++ b/src/main/java/org/apache/sling/cli/impl/http/HttpClientFactory.java
@@ -82,15 +82,14 @@ public class HttpClientFactory {
 
     private BasicCredentialsProvider newCredentialsProvider() {
         Credentials asf = credentialsService.getAsfCredentials();
-        Credentials jira = credentialsService.getJiraCredentials();
-        
+
         BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
         credentialsProvider.setCredentials(new AuthScope(nexusHost, nexusPort),
                 new UsernamePasswordCredentials(asf.getUsername(), asf.getPassword()));
         credentialsProvider.setCredentials(new AuthScope("reporter.apache.org", 443), 
                 new UsernamePasswordCredentials(asf.getUsername(), asf.getPassword()));
         credentialsProvider.setCredentials(new AuthScope(jiraHost, jiraPort), 
-                new UsernamePasswordCredentials(jira.getUsername(), jira.getPassword()));
+                new UsernamePasswordCredentials(asf.getUsername(), asf.getPassword()));
         return credentialsProvider;
     }
     
diff --git a/src/test/java/org/apache/sling/cli/impl/CredentialsServiceTest.java b/src/test/java/org/apache/sling/cli/impl/CredentialsServiceTest.java
index 571adba..6d241bf 100644
--- a/src/test/java/org/apache/sling/cli/impl/CredentialsServiceTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/CredentialsServiceTest.java
@@ -44,9 +44,6 @@ public class CredentialsServiceTest {
             assertThat(creds.getAsfCredentials().getUsername(), equalTo("asf.username.val"));
             assertThat(creds.getAsfCredentials().getPassword(), equalTo("asf.password.val"));
             
-            assertThat(creds.getJiraCredentials().getUsername(), equalTo("jira.username.val"));
-            assertThat(creds.getJiraCredentials().getPassword(), equalTo("jira.password.val"));
-            
         } finally {
             for ( String prop : VALID_PROPS ) {
                 System.clearProperty(prop);
diff --git a/src/test/java/org/apache/sling/cli/impl/jira/MockJira.java b/src/test/java/org/apache/sling/cli/impl/jira/MockJira.java
index 5c411e9..73ccb5b 100644
--- a/src/test/java/org/apache/sling/cli/impl/jira/MockJira.java
+++ b/src/test/java/org/apache/sling/cli/impl/jira/MockJira.java
@@ -32,8 +32,8 @@ import com.sun.net.httpserver.HttpServer;
 
 public class MockJira extends ExternalResource {
     
-    static final String AUTH_USER = "jira-user";
-    static final String AUTH_PWD = "jira-password";
+    static final String AUTH_USER = "asf-user";
+    static final String AUTH_PWD = "asf-password";
     
     public static void main(String[] args) throws Throwable {
         
diff --git a/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java b/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
index 9c5c0cf..bdf1cda 100644
--- a/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
@@ -41,8 +41,6 @@ public class VersionClientTest {
     static {
         SYSTEM_PROPS.put("asf.username", "asf-user");
         SYSTEM_PROPS.put("asf.password", "asf-password");
-        SYSTEM_PROPS.put("jira.username", MockJira.AUTH_USER);
-        SYSTEM_PROPS.put("jira.password", MockJira.AUTH_PWD);
     }
     
     @Rule


[sling-org-apache-sling-committer-cli] 02/02: SLING-8864 - Report authentication errors immediately without looking at the response's body

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-committer-cli.git

commit 59bd129e61683ec6ceb405cf0c9771e5b3ea7383
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Wed Dec 11 14:37:49 2019 +0100

    SLING-8864 - Report authentication errors immediately without looking at the response's body
    
    * simplified HttpClientFactoryTest since the logic to work with test system properties
    was already available in SystemPropertiesRule
---
 .../sling/cli/impl/http/HttpClientFactoryTest.java | 30 ++++++------------
 .../sling/cli/impl/jira/VersionClientTest.java     |  1 +
 .../impl/{jira => junit}/SystemPropertiesRule.java | 36 ++++++++++++----------
 .../cli/impl/nexus/RepositoryServiceTest.java      |  2 +-
 .../cli/impl/pgp/PGPSignatureValidatorTest.java    |  2 +-
 5 files changed, 31 insertions(+), 40 deletions(-)

diff --git a/src/test/java/org/apache/sling/cli/impl/http/HttpClientFactoryTest.java b/src/test/java/org/apache/sling/cli/impl/http/HttpClientFactoryTest.java
index e468314..d327203 100644
--- a/src/test/java/org/apache/sling/cli/impl/http/HttpClientFactoryTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/http/HttpClientFactoryTest.java
@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.sling.cli.impl.CredentialsService;
+import org.apache.sling.cli.impl.junit.SystemPropertiesRule;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.After;
 import org.junit.Before;
@@ -40,27 +41,20 @@ import static org.junit.Assert.assertTrue;
 public class HttpClientFactoryTest {
 
     private HttpServer server;
-    private Map<String, String> replacedProperties;
-    private Map<String, String> testProperties;
+    private static final Map<String, String> SYSTEM_PROPS = new HashMap<>();
 
+    static {
+        SYSTEM_PROPS.put("asf.username", "asf-user");
+        SYSTEM_PROPS.put("asf.password", "asf-password");
+    }
     @Rule
     public OsgiContext osgiContext = new OsgiContext();
 
+    @Rule
+    public SystemPropertiesRule systemProperties = new SystemPropertiesRule(SYSTEM_PROPS);
+
     @Before
     public void before() throws Throwable {
-        replacedProperties = new HashMap<>();
-        testProperties = new HashMap<>();
-        testProperties.put("asf.username", "asf.username");
-        testProperties.put("asf.password", "asf.password");
-        testProperties.put("jira.username", "jira.username");
-        testProperties.put("jira.password", "jira.password");
-        for (Map.Entry<String, String> testProperty : testProperties.entrySet()) {
-            String originalValue = System.getProperty(testProperty.getKey());
-            if (originalValue != null) {
-                replacedProperties.put(testProperty.getKey(), originalValue);
-            }
-            System.setProperty(testProperty.getKey(), testProperty.getValue());
-        }
         server = HttpServer.create(new InetSocketAddress("localhost", 0), 0);
         HttpContext rootContext = server.createContext("/");
         rootContext.setHandler(ex -> {
@@ -93,11 +87,5 @@ public class HttpClientFactoryTest {
     @After
     public void after() {
         server.stop(0);
-        for (String testProperty : testProperties.keySet()) {
-            System.clearProperty(testProperty);
-        }
-        for (Map.Entry<String, String> replacedProperty : replacedProperties.entrySet()) {
-            System.setProperty(replacedProperty.getKey(), replacedProperty.getValue());
-        }
     }
 }
diff --git a/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java b/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
index bdf1cda..ae75090 100644
--- a/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/jira/VersionClientTest.java
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import org.apache.sling.cli.impl.CredentialsService;
 import org.apache.sling.cli.impl.http.HttpClientFactory;
+import org.apache.sling.cli.impl.junit.SystemPropertiesRule;
 import org.apache.sling.cli.impl.release.Release;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
diff --git a/src/test/java/org/apache/sling/cli/impl/jira/SystemPropertiesRule.java b/src/test/java/org/apache/sling/cli/impl/junit/SystemPropertiesRule.java
similarity index 50%
rename from src/test/java/org/apache/sling/cli/impl/jira/SystemPropertiesRule.java
rename to src/test/java/org/apache/sling/cli/impl/junit/SystemPropertiesRule.java
index c6273b5..81a665a 100644
--- a/src/test/java/org/apache/sling/cli/impl/jira/SystemPropertiesRule.java
+++ b/src/test/java/org/apache/sling/cli/impl/junit/SystemPropertiesRule.java
@@ -1,20 +1,22 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sling.cli.impl.jira;
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements.  See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership.  The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License.  You may obtain a copy of the License at
+ ~
+ ~   http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied.  See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+package org.apache.sling.cli.impl.junit;
 
 import java.util.HashMap;
 import java.util.Map;
diff --git a/src/test/java/org/apache/sling/cli/impl/nexus/RepositoryServiceTest.java b/src/test/java/org/apache/sling/cli/impl/nexus/RepositoryServiceTest.java
index 6f7cdea..bc48786 100644
--- a/src/test/java/org/apache/sling/cli/impl/nexus/RepositoryServiceTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/nexus/RepositoryServiceTest.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
 import org.apache.commons.io.IOUtils;
 import org.apache.sling.cli.impl.CredentialsService;
 import org.apache.sling.cli.impl.http.HttpClientFactory;
-import org.apache.sling.cli.impl.jira.SystemPropertiesRule;
+import org.apache.sling.cli.impl.junit.SystemPropertiesRule;
 import org.apache.sling.cli.impl.release.Release;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
diff --git a/src/test/java/org/apache/sling/cli/impl/pgp/PGPSignatureValidatorTest.java b/src/test/java/org/apache/sling/cli/impl/pgp/PGPSignatureValidatorTest.java
index 43f3a39..ce9a2f9 100644
--- a/src/test/java/org/apache/sling/cli/impl/pgp/PGPSignatureValidatorTest.java
+++ b/src/test/java/org/apache/sling/cli/impl/pgp/PGPSignatureValidatorTest.java
@@ -25,7 +25,7 @@ import java.util.Map;
 
 import org.apache.sling.cli.impl.CredentialsService;
 import org.apache.sling.cli.impl.http.HttpClientFactory;
-import org.apache.sling.cli.impl.jira.SystemPropertiesRule;
+import org.apache.sling.cli.impl.junit.SystemPropertiesRule;
 import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
 import org.junit.Before;
 import org.junit.Rule;