Enforce that channels names must start with /

Fixes: #5
Change-Id: I663e7c0802b750e93e904a8d4edaa1f2bd5d0959
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 46e84f5..4e1316d 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -338,6 +338,9 @@
       if (c->name()->string_view().back() == '/') {
         LOG(FATAL) << "Channel names can't end with '/'";
       }
+      if (c->name()->string_view().front() != '/') {
+        LOG(FATAL) << "Channel names must start with '/'";
+      }
       if (c->name()->string_view().find("//") != std::string_view::npos) {
         LOG(FATAL) << ": Invalid channel name " << c->name()->string_view()
                    << ", can't use //.";
diff --git a/aos/configuration_test.cc b/aos/configuration_test.cc
index 823f43c..cb44f1b 100644
--- a/aos/configuration_test.cc
+++ b/aos/configuration_test.cc
@@ -136,6 +136,13 @@
         LOG(FATAL) << "Foo";
       },
       "Invalid channel name");
+  EXPECT_DEATH(
+      {
+        FlatbufferDetachedBuffer<Configuration> config =
+            ReadConfig(ArtifactPath("aos/testdata/invalid_channel_name4.json"));
+        LOG(FATAL) << "Foo";
+      },
+      "Channel names must start with '/'");
 }
 
 // Tests that we can modify a config with a json snippet.
diff --git a/aos/testdata/BUILD b/aos/testdata/BUILD
index 82e67f9..8b87682 100644
--- a/aos/testdata/BUILD
+++ b/aos/testdata/BUILD
@@ -20,6 +20,7 @@
         "invalid_channel_name1.json",
         "invalid_channel_name2.json",
         "invalid_channel_name3.json",
+        "invalid_channel_name4.json",
         "invalid_destination_node.json",
         "invalid_logging_configuration.json",
         "invalid_nodes.json",
diff --git a/aos/testdata/invalid_channel_name4.json b/aos/testdata/invalid_channel_name4.json
new file mode 100644
index 0000000..44ed8db
--- /dev/null
+++ b/aos/testdata/invalid_channel_name4.json
@@ -0,0 +1,9 @@
+{
+  "channels": [
+    {
+      "name": "foo",
+      "type": ".aos.bar",
+      "max_size": 5
+    }
+  ]
+}