radicle: Fix config loading with bad alias
Previously, a config would load fine with an invalid alias, due to how serde is configured for the `Alias` type. This fixes it.
This commit is contained in:
parent
8b1dc8f168
commit
057af40ea3
|
|
@ -0,0 +1,17 @@
|
|||
Note that aliases must not be longer than 32 bytes, or you will get an error.
|
||||
There are other rules as well:
|
||||
|
||||
``` (fail)
|
||||
$ rad auth --alias "5fad63fe6b339fa92c588d926121bea6240773a7"
|
||||
✗ Error: rad auth: alias cannot be greater than 32 bytes
|
||||
```
|
||||
|
||||
``` (fail)
|
||||
$ rad auth --alias "john doe"
|
||||
✗ Error: rad auth: alias cannot contain whitespace or control characters
|
||||
```
|
||||
|
||||
``` (fail)
|
||||
$ rad auth --alias ""
|
||||
✗ Error: rad auth: alias cannot be empty
|
||||
```
|
||||
|
|
@ -25,6 +25,7 @@ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
|||
```
|
||||
|
||||
You can also show your alias:
|
||||
|
||||
```
|
||||
$ rad self --alias
|
||||
alice
|
||||
|
|
|
|||
|
|
@ -128,6 +128,11 @@ fn rad_auth() {
|
|||
test("examples/rad-auth.md", Path::new("."), None, []).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_auth_errors() {
|
||||
test("examples/rad-auth-errors.md", Path::new("."), None, []).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rad_issue() {
|
||||
let mut environment = Environment::new();
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ impl PartialOrd for SyncStatus {
|
|||
|
||||
/// Node alias.
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(try_from = "String", into = "String")]
|
||||
pub struct Alias(String);
|
||||
|
||||
impl Alias {
|
||||
|
|
@ -288,6 +289,14 @@ impl FromStr for Alias {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<String> for Alias {
|
||||
type Error = AliasError;
|
||||
|
||||
fn try_from(value: String) -> Result<Self, Self::Error> {
|
||||
Alias::from_str(&value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Options passed to the "connect" node command.
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ConnectOptions {
|
||||
|
|
|
|||
Loading…
Reference in New Issue