Repository: conan-io/conan

Issue:
CONAN_LOGIN_USERNAME and CONAN_PASSWORD are ignored in non-interactive mode
Conan 1.3.2

To reproduce:
1. Run `conan user -c`
2. Set `CONAN_LOGIN_USERNAME`, `CONAN_PASSWORD` and `CONAN_NON_INTERACTIVE` environment variables.
3. Run `conan upload -r staging` to remove which requires authentication.

**Expected result**: Conan uses credentials stored in environment variables (as was in Conan 1.2)
**Actual result**: Upload fails with message:
```
Please log in to "staging" to perform this action. Execute "conan user" command.
ERROR: Conan interactive mode disabled. [Remote: staging]
```

My best guess is that in `userio.py`
```python
    def request_login(self, remote_name, username=None):
        """Request user to input their name and password
        :param username If username is specified it only request password"""
        self._raise_if_non_interactive()
```
call to `self._raise_if_non_interactive()` is unnecessary as this check performed by functions called from it (Having prompt printed is not that ugly, or move this check closer to `conan user` command).

Option to always require explicit `conan user` is also possible, although feels little bit inconsistent and makes use of credentials variables pointless.


Discussion:
You are right, thanks for the perfect analysis of the issue, that is exactly the problem.


Resolving patch:
diff --git a/conans/client/userio.py b/conans/client/userio.py
--- a/conans/client/userio.py
+++ b/conans/client/userio.py
@@ -40,17 +40,17 @@ def get_pass(self):
     def request_login(self, remote_name, username=None):
         """Request user to input their name and password
         :param username If username is specified it only request password"""
-        self._raise_if_non_interactive()
         user_input = ''
         while not username:
             try:
-                self.out.write("Remote '%s' username: " % remote_name)
+                if self._interactive:
+                    self.out.write("Remote '%s' username: " % remote_name)
                 user_input = self.get_username(remote_name)
                 username = Username(user_input)
             except InvalidNameException:
                 self.out.error('%s is not a valid username' % user_input)
-
-        self.out.write('Please enter a password for "%s" account: ' % username)
+        if self._interactive:
+            self.out.write('Please enter a password for "%s" account: ' % username)
         try:
             pwd = self.get_password(remote_name)
         except ConanException:


Test patch:
diff --git a/conans/test/command/upload_test.py b/conans/test/command/upload_test.py
--- a/conans/test/command/upload_test.py
+++ b/conans/test/command/upload_test.py
@@ -420,6 +420,7 @@ def upload_login_prompt_disabled_user_not_authenticated_test(self):
         self.assertNotIn("Uploading conanmanifest.txt", client.out)
         self.assertNotIn("Uploading conanfile.py", client.out)
         self.assertNotIn("Uploading conan_export.tgz", client.out)
+        self.assertNotIn("Please enter a password for \"lasote\" account:", client.out)
 
     def upload_login_prompt_disabled_user_authenticated_test(self):
         """ When a user is authenticated, uploads should work even when login prompt has been disabled.