Fix display formats for access methods (#4220)
This commit is contained in:
parent
24c8b06c93
commit
7b06e8b09a
3 changed files with 8 additions and 26 deletions
core/src
|
@ -192,22 +192,17 @@ impl Display for AccessType {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
AccessType::Jwt(ac) => {
|
||||
f.write_str(" JWT")?;
|
||||
match &ac.verify {
|
||||
JwtAccessVerify::Key(ref v) => {
|
||||
write!(f, " ALGORITHM {} KEY {}", v.alg, quote_str(&v.key))?
|
||||
}
|
||||
JwtAccessVerify::Jwks(ref v) => write!(f, " JWKS {}", quote_str(&v.url))?,
|
||||
}
|
||||
write!(f, "JWT {}", ac)?;
|
||||
}
|
||||
AccessType::Record(ac) => {
|
||||
f.write_str(" RECORD")?;
|
||||
f.write_str("RECORD")?;
|
||||
if let Some(ref v) = ac.signup {
|
||||
write!(f, " SIGNUP {v}")?
|
||||
}
|
||||
if let Some(ref v) = ac.signin {
|
||||
write!(f, " SIGNIN {v}")?
|
||||
}
|
||||
write!(f, " WITH JWT {}", ac.jwt)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -246,7 +241,7 @@ impl Display for JwtAccess {
|
|||
write!(f, "ALGORITHM {} KEY {}", v.alg, quote_str(&v.key))?;
|
||||
}
|
||||
JwtAccessVerify::Jwks(ref v) => {
|
||||
write!(f, "JWKS {}", quote_str(&v.url),)?;
|
||||
write!(f, "URL {}", quote_str(&v.url),)?;
|
||||
}
|
||||
}
|
||||
if let Some(iss) = &self.issue {
|
||||
|
@ -265,7 +260,7 @@ impl InfoStructure for JwtAccess {
|
|||
acc.insert("key".to_string(), v.key.into());
|
||||
}
|
||||
JwtAccessVerify::Jwks(v) => {
|
||||
acc.insert("jwks".to_string(), v.url.into());
|
||||
acc.insert("url".to_string(), v.url.into());
|
||||
}
|
||||
}
|
||||
if let Some(v) = self.issue {
|
||||
|
|
|
@ -131,22 +131,8 @@ impl Display for DefineAccessStatement {
|
|||
if self.if_not_exists {
|
||||
write!(f, " IF NOT EXISTS")?
|
||||
}
|
||||
write!(f, " {} ON {}", self.name, self.base)?;
|
||||
match &self.kind {
|
||||
AccessType::Jwt(ac) => {
|
||||
write!(f, " TYPE JWT {}", ac)?;
|
||||
}
|
||||
AccessType::Record(ac) => {
|
||||
write!(f, " TYPE RECORD")?;
|
||||
if let Some(ref v) = ac.signup {
|
||||
write!(f, " SIGNUP {v}")?
|
||||
}
|
||||
if let Some(ref v) = ac.signin {
|
||||
write!(f, " SIGNIN {v}")?
|
||||
}
|
||||
write!(f, " WITH JWT {}", ac.jwt)?;
|
||||
}
|
||||
}
|
||||
// The specific access method definition is displayed by AccessType
|
||||
write!(f, " {} ON {} TYPE {}", self.name, self.base, self.kind)?;
|
||||
// Always print relevant durations so defaults can be changed in the future
|
||||
// If default values were not printed, exports would not be forward compatible
|
||||
// None values need to be printed, as they are different from the default values
|
||||
|
|
|
@ -1130,6 +1130,7 @@ fn parse_define_access_record() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_define_access_record_with_jwt() {
|
||||
let res = test_parse!(
|
||||
parse_stmt,
|
||||
|
|
Loading…
Reference in a new issue