@@ -19,7 +19,6 @@ package main
19
19
import (
20
20
"bytes"
21
21
"encoding/json"
22
- "fmt"
23
22
"io/ioutil"
24
23
"os"
25
24
"testing"
@@ -69,7 +68,7 @@ func TestCLIFeedUpdate(t *testing.T) {
69
68
hexData }
70
69
71
70
// create an update and expect an exit without errors
72
- log .Info (fmt . Sprintf ( "updating a feed with 'swarm feed update'" ) )
71
+ log .Info ("updating a feed with 'swarm feed update'" )
73
72
cmd := runSwarm (t , flags ... )
74
73
cmd .ExpectExit ()
75
74
@@ -116,7 +115,7 @@ func TestCLIFeedUpdate(t *testing.T) {
116
115
"--user" , address .Hex (),
117
116
}
118
117
119
- log .Info (fmt . Sprintf ( "getting feed info with 'swarm feed info'" ) )
118
+ log .Info ("getting feed info with 'swarm feed info'" )
120
119
cmd = runSwarm (t , flags ... )
121
120
_ , matches := cmd .ExpectRegexp (`.*` ) // regex hack to extract stdout
122
121
cmd .ExpectExit ()
@@ -141,9 +140,9 @@ func TestCLIFeedUpdate(t *testing.T) {
141
140
"--topic" , topic .Hex (),
142
141
}
143
142
144
- log .Info (fmt . Sprintf ( "Publishing manifest with 'swarm feed create'" ) )
143
+ log .Info ("Publishing manifest with 'swarm feed create'" )
145
144
cmd = runSwarm (t , flags ... )
146
- _ , matches = cmd .ExpectRegexp (`[a-f\d]{64}` ) // regex hack to extract stdout
145
+ _ , matches = cmd .ExpectRegexp (`[a-f\d]{64}` )
147
146
cmd .ExpectExit ()
148
147
149
148
manifestAddress := matches [0 ] // read the received feed manifest
@@ -162,4 +161,36 @@ func TestCLIFeedUpdate(t *testing.T) {
162
161
if ! bytes .Equal (data , retrieved ) {
163
162
t .Fatalf ("Received %s, expected %s" , retrieved , data )
164
163
}
164
+
165
+ // test publishing a manifest for a different user
166
+ flags = []string {
167
+ "--bzzapi" , srv .URL ,
168
+ "feed" , "create" ,
169
+ "--topic" , topic .Hex (),
170
+ "--user" , "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" , // different user
171
+ }
172
+
173
+ log .Info ("Publishing manifest with 'swarm feed create' for a different user" )
174
+ cmd = runSwarm (t , flags ... )
175
+ _ , matches = cmd .ExpectRegexp (`[a-f\d]{64}` )
176
+ cmd .ExpectExit ()
177
+
178
+ manifestAddress = matches [0 ] // read the received feed manifest
179
+
180
+ // now let's try to update that user's manifest which we don't have the private key for
181
+ flags = []string {
182
+ "--bzzapi" , srv .URL ,
183
+ "--bzzaccount" , pkFileName ,
184
+ "feed" , "update" ,
185
+ "--manifest" , manifestAddress ,
186
+ hexData }
187
+
188
+ // create an update and expect an error given there is a user mismatch
189
+ log .Info ("updating a feed with 'swarm feed update'" )
190
+ cmd = runSwarm (t , flags ... )
191
+ cmd .ExpectRegexp ("Fatal:.*" ) // best way so far to detect a failure.
192
+ cmd .ExpectExit ()
193
+ if cmd .ExitStatus () == 0 {
194
+ t .Fatal ("Expected nonzero exit code when updating a manifest with the wrong user. Got 0." )
195
+ }
165
196
}
0 commit comments