Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Fix config loading with bad alias
cloudhead committed 2 years ago
commit 057af40ea360b4372bab65c4a60a8555afc58cf5
parent 8b1dc8f168be7bed29b8a8b2477ee53ec358b2c3
4 files changed +32 -0
added radicle-cli/examples/rad-auth-errors.md
@@ -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
+
```
modified radicle-cli/examples/rad-auth.md
@@ -25,6 +25,7 @@ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
```

You can also show your alias:
+

```
$ rad self --alias
alice
modified radicle-cli/tests/commands.rs
@@ -129,6 +129,11 @@ fn rad_auth() {
}

#[test]
+
fn rad_auth_errors() {
+
    test("examples/rad-auth-errors.md", Path::new("."), None, []).unwrap();
+
}
+

+
#[test]
fn rad_issue() {
    let mut environment = Environment::new();
    let profile = environment.profile(config::profile("alice"));
modified radicle/src/node.rs
@@ -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 {