record-tester: added access control testing#220
Conversation
| glog.V(model.SHORT).Infof("RTMP: %s", rtmpURL) | ||
| glog.V(model.SHORT).Infof("MEDIA: %s", mediaURL) | ||
|
|
||
| if rt.accessControl && (rt.signingKey != "" && rt.publicKey != "") { |
There was a problem hiding this comment.
Having accessControl and not the signing key should be an explicit fatal error. We should not ignore the setting because another required option was not provided, it is better to just fail the whole test.
| if rt.accessControl && (rt.signingKey != "" && rt.publicKey != "") { | |
| if rt.accessControl { | |
| if rt.signingKey == "" || rt.publicKey == "" { | |
| msg := "Signing key and public key are required for access control test" | |
| glog.Fatal(msg) | |
| return 1, errors.New(msg) // (Fatal log above already exits the process but you know just in case, leave it clear here that we end with an error) | |
| } |
| } else { | ||
| glog.Warningf("No access control for stream id=%s playbackId=%s name=%s mediaURL=%s", stream.ID, stream.PlaybackID, streamName, mediaURL) | ||
| return 2, nil | ||
| } |
There was a problem hiding this comment.
No reason to log this as a warning or returning. Executing a test without access control is perfectly acceptable. And we already log above when we use access control so no need to log when we don't.
| } else { | |
| glog.Warningf("No access control for stream id=%s playbackId=%s name=%s mediaURL=%s", stream.ID, stream.PlaybackID, streamName, mediaURL) | |
| return 2, nil | |
| } | |
| } |
| // uploader := testers.NewRtmpStreamer(gctx, rtmpURL) | ||
| // uploader.StartUpload(fileName, rtmpURL, -1, 30*time.Second) | ||
| return es, err | ||
| return 0, err |
There was a problem hiding this comment.
nit: We know err is nil here so we can be explicit. Just so one doesn't start wondering here where this err could be instead of nil (from what I checked, it can't)
| return 0, err | |
| return 0, nil |
| if err != nil { | ||
| glog.Errorf("Unable to parse provided signing key for access control signingKey=%s", rt.signingKey) | ||
| } | ||
|
|
||
| token, err := unsignedToken.SignedString(pk) | ||
|
|
||
| if err != nil { | ||
| glog.Errorf("Unable to sign JWT with provided private key for access control signingKey=%s", rt.signingKey) | ||
| } |
There was a problem hiding this comment.
We need to return all these errors. Cannot just log.
| if err != nil { | |
| glog.Errorf("Unable to parse provided signing key for access control signingKey=%s", rt.signingKey) | |
| } | |
| token, err := unsignedToken.SignedString(pk) | |
| if err != nil { | |
| glog.Errorf("Unable to sign JWT with provided private key for access control signingKey=%s", rt.signingKey) | |
| } | |
| if err != nil { | |
| glog.Errorf("Unable to parse provided signing key for access control signingKey=%s", rt.signingKey) | |
| return "", err | |
| } | |
| token, err := unsignedToken.SignedString(pk) | |
| if err != nil { | |
| glog.Errorf("Unable to sign JWT with provided private key for access control signingKey=%s", rt.signingKey) | |
| return "", err | |
| } |
Fixes #204