veyron/runtimes/google/naming: Bugfix in error propagation and test
setup.
(1) The glob implementation would not extract the "application error"
(error returned by the server's implementation of the Glob method)
but instead only return framework errors. Also, it was not calling
ipc.Call.Finish, which is not strictly necessary but considered good
practice.
(2) The authorization policy in the test was the "default" one, which
should fail when the client and server are two independent principals.
It just happened to work on in the test because of the unfortunate
use of a global "trusted keys" map in the old security model. However,
this will be going away with the new security model and the
"allow everyone" policy change in this test seems to reflect intent
more accurately.
Change-Id: I630e00ba6f77000e75dd1c5b3a53ae288edd1419
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 8d37312..ad6a9b0 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -112,10 +112,14 @@
return nil
}
+type allowEveryoneAuthorizer struct{}
+
+func (allowEveryoneAuthorizer) Authorize(security.Context) error { return nil }
+
type dispatcher struct{}
func (d *dispatcher) Lookup(suffix, method string) (ipc.Invoker, security.Authorizer, error) {
- return ipc.ReflectInvoker(&testServer{suffix}), nil, nil
+ return ipc.ReflectInvoker(&testServer{suffix}), allowEveryoneAuthorizer{}, nil
}
func knockKnock(t *testing.T, runtime veyron2.Runtime, name string) {
diff --git a/runtimes/google/naming/namespace/glob.go b/runtimes/google/naming/namespace/glob.go
index 4b3d296..0992eaa 100644
--- a/runtimes/google/naming/namespace/glob.go
+++ b/runtimes/google/naming/namespace/glob.go
@@ -60,7 +60,7 @@
var e mountEntry
err := call.Recv(&e)
if err == io.EOF {
- return nil
+ break
}
if err != nil {
return err
@@ -88,10 +88,11 @@
l.PushBack(x)
}
- if err := call.Finish(); err != nil {
+ var globerr error
+ if err := call.Finish(&globerr); err != nil {
return err
}
- return nil
+ return globerr
}
return lastErr