You've already forked AstralRinth
forked from didirus/AstralRinth
Test permissions use api (#784)
* initial push * fmt; clippy --------- Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
@@ -10,7 +10,10 @@ use labrinth::auth::oauth::{
|
||||
};
|
||||
use reqwest::header::{AUTHORIZATION, LOCATION};
|
||||
|
||||
use crate::common::{api_common::Api, asserts::assert_status};
|
||||
use crate::common::{
|
||||
api_common::{Api, AppendsOptionalPat},
|
||||
asserts::assert_status,
|
||||
};
|
||||
|
||||
use super::ApiV3;
|
||||
|
||||
@@ -22,7 +25,7 @@ impl ApiV3 {
|
||||
scope: Option<&str>,
|
||||
redirect_uri: Option<&str>,
|
||||
state: Option<&str>,
|
||||
user_pat: &str,
|
||||
user_pat: Option<&str>,
|
||||
) -> String {
|
||||
let auth_resp = self
|
||||
.oauth_authorize(client_id, scope, redirect_uri, state, user_pat)
|
||||
@@ -42,21 +45,18 @@ impl ApiV3 {
|
||||
scope: Option<&str>,
|
||||
redirect_uri: Option<&str>,
|
||||
state: Option<&str>,
|
||||
pat: &str,
|
||||
pat: Option<&str>,
|
||||
) -> ServiceResponse {
|
||||
let uri = generate_authorize_uri(client_id, scope, redirect_uri, state);
|
||||
let req = TestRequest::get()
|
||||
.uri(&uri)
|
||||
.append_header((AUTHORIZATION, pat))
|
||||
.to_request();
|
||||
let req = TestRequest::get().uri(&uri).append_pat(pat).to_request();
|
||||
self.call(req).await
|
||||
}
|
||||
|
||||
pub async fn oauth_accept(&self, flow: &str, pat: &str) -> ServiceResponse {
|
||||
pub async fn oauth_accept(&self, flow: &str, pat: Option<&str>) -> ServiceResponse {
|
||||
self.call(
|
||||
TestRequest::post()
|
||||
.uri("/_internal/oauth/accept")
|
||||
.append_header((AUTHORIZATION, pat))
|
||||
.append_pat(pat)
|
||||
.set_json(RespondToOAuthClientScopes {
|
||||
flow: flow.to_string(),
|
||||
})
|
||||
@@ -65,11 +65,11 @@ impl ApiV3 {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn oauth_reject(&self, flow: &str, pat: &str) -> ServiceResponse {
|
||||
pub async fn oauth_reject(&self, flow: &str, pat: Option<&str>) -> ServiceResponse {
|
||||
self.call(
|
||||
TestRequest::post()
|
||||
.uri("/_internal/oauth/reject")
|
||||
.append_header((AUTHORIZATION, pat))
|
||||
.append_pat(pat)
|
||||
.set_json(RespondToOAuthClientScopes {
|
||||
flow: flow.to_string(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user