Fix display formats for access methods ()

This commit is contained in:
Gerard Guillemas Martos 2024-06-19 13:27:59 +02:00 committed by GitHub
parent 24c8b06c93
commit 7b06e8b09a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 26 deletions
core/src
sql
access_type.rs
statements/define
syn/parser/test

View file

@ -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 {

View file

@ -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

View file

@ -1130,6 +1130,7 @@ fn parse_define_access_record() {
}
}
#[test]
fn parse_define_access_record_with_jwt() {
let res = test_parse!(
parse_stmt,