add password auth testing
This commit is contained in:
		
							parent
							
								
									9908d5086c
								
							
						
					
					
						commit
						dc7997beba
					
				
					 1 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -5,7 +5,7 @@ use forgejo_api::Forgejo;
 | 
			
		|||
async fn ci() -> eyre::Result<()> {
 | 
			
		||||
    let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL")?)?;
 | 
			
		||||
    let token = std::env::var("FORGEJO_API_CI_TOKEN")?;
 | 
			
		||||
    let api = Forgejo::new(&token, url)?;
 | 
			
		||||
    let api = Forgejo::new(forgejo_api::Auth::Token(&token), url)?;
 | 
			
		||||
 | 
			
		||||
    let mut results = Vec::new();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -54,6 +54,22 @@ async fn user(api: &forgejo_api::Forgejo) -> eyre::Result<()> {
 | 
			
		|||
    let followers = api.get_followers("TestingAdmin").await?;
 | 
			
		||||
    ensure!(followers == Some(Vec::new()), "follower list not empty");
 | 
			
		||||
 | 
			
		||||
    let url = url::Url::parse(&std::env::var("FORGEJO_API_CI_INSTANCE_URL")?)?;
 | 
			
		||||
    let password_api = Forgejo::new(
 | 
			
		||||
        forgejo_api::Auth::Password {
 | 
			
		||||
            username: "TestingAdmin",
 | 
			
		||||
            password: "password",
 | 
			
		||||
            mfa: None,
 | 
			
		||||
        },
 | 
			
		||||
        url,
 | 
			
		||||
    )
 | 
			
		||||
    .wrap_err("failed to log in using username and password")?;
 | 
			
		||||
 | 
			
		||||
    ensure!(
 | 
			
		||||
        api.myself().await? == password_api.myself().await?,
 | 
			
		||||
        "users not equal comparing token-auth and pass-auth"
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    Ok(())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue