|
1 | | -#[cfg(feature = "native-auth")] |
2 | 1 | use anyhow::Result; |
3 | 2 | use assert_cmd::assert::OutputAssertExt; |
4 | | -#[cfg(feature = "native-auth")] |
5 | 3 | use assert_fs::{fixture::PathChild, prelude::FileWriteStr}; |
6 | 4 | #[cfg(feature = "native-auth")] |
7 | 5 | use uv_static::EnvVars; |
@@ -778,6 +776,88 @@ fn login_text_store() { |
778 | 776 | ); |
779 | 777 | } |
780 | 778 |
|
| 779 | +#[test] |
| 780 | +#[allow(clippy::disallowed_types)] |
| 781 | +fn login_password_stdin() -> Result<()> { |
| 782 | + let context = TestContext::new_with_versions(&[]); |
| 783 | + |
| 784 | + // Create a temporary file with the password |
| 785 | + let password_file = context.temp_dir.child("password.txt"); |
| 786 | + password_file.write_str("secret-password")?; |
| 787 | + |
| 788 | + // Login with password from stdin |
| 789 | + uv_snapshot!(context.auth_login() |
| 790 | + .arg("https://example.com/simple") |
| 791 | + .arg("--username") |
| 792 | + .arg("testuser") |
| 793 | + .arg("--password") |
| 794 | + .arg("-") |
| 795 | + .stdin(std::fs::File::open(password_file)?), @r" |
| 796 | + success: true |
| 797 | + exit_code: 0 |
| 798 | + ----- stdout ----- |
| 799 | +
|
| 800 | + ----- stderr ----- |
| 801 | + Stored credentials for testuser@https://example.com/ |
| 802 | + " |
| 803 | + ); |
| 804 | + |
| 805 | + // Verify the credentials work by retrieving the token |
| 806 | + uv_snapshot!(context.auth_token() |
| 807 | + .arg("https://example.com/simple") |
| 808 | + .arg("--username") |
| 809 | + .arg("testuser"), @r" |
| 810 | + success: true |
| 811 | + exit_code: 0 |
| 812 | + ----- stdout ----- |
| 813 | + secret-password |
| 814 | +
|
| 815 | + ----- stderr ----- |
| 816 | + " |
| 817 | + ); |
| 818 | + |
| 819 | + Ok(()) |
| 820 | +} |
| 821 | + |
| 822 | +#[test] |
| 823 | +#[allow(clippy::disallowed_types)] |
| 824 | +fn login_token_stdin() -> Result<()> { |
| 825 | + let context = TestContext::new_with_versions(&[]); |
| 826 | + |
| 827 | + // Create a temporary file with the token |
| 828 | + let token_file = context.temp_dir.child("token.txt"); |
| 829 | + token_file.write_str("secret-token")?; |
| 830 | + |
| 831 | + // Login with token from stdin |
| 832 | + uv_snapshot!(context.auth_login() |
| 833 | + .arg("https://example.com/simple") |
| 834 | + .arg("--token") |
| 835 | + .arg("-") |
| 836 | + .stdin(std::fs::File::open(token_file)?), @r" |
| 837 | + success: true |
| 838 | + exit_code: 0 |
| 839 | + ----- stdout ----- |
| 840 | +
|
| 841 | + ----- stderr ----- |
| 842 | + Stored credentials for https://example.com/ |
| 843 | + " |
| 844 | + ); |
| 845 | + |
| 846 | + // Verify the credentials work by retrieving the token |
| 847 | + uv_snapshot!(context.auth_token() |
| 848 | + .arg("https://example.com/simple"), @r" |
| 849 | + success: true |
| 850 | + exit_code: 0 |
| 851 | + ----- stdout ----- |
| 852 | + secret-token |
| 853 | +
|
| 854 | + ----- stderr ----- |
| 855 | + " |
| 856 | + ); |
| 857 | + |
| 858 | + Ok(()) |
| 859 | +} |
| 860 | + |
781 | 861 | #[test] |
782 | 862 | fn token_text_store() { |
783 | 863 | let context = TestContext::new_with_versions(&[]); |
|
0 commit comments