Skip to content

Commit

Permalink
Hopefully now
Browse files Browse the repository at this point in the history
  • Loading branch information
kleewho committed Sep 18, 2023
1 parent 2f6b5fc commit 95f655f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion files_download_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ func (b *downloadFileBuilder) Execute() (*PNDownloadFileResponse, StatusResponse

var respDL *PNDownloadFileResponse
if b.opts.CipherKey == "" && b.opts.pubnub.cryptoModule == nil {

respDL = &PNDownloadFileResponse{
File: resp.Body,
}
} else {
var e error
cryptoModule := b.opts.pubnub.getCryptoModule()
Expand Down
21 changes: 12 additions & 9 deletions publish_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ func AssertSuccessPublishGetMeta(t *testing.T, expectedString string, message in
assert.Nil(err1)
}

func AssertSuccessPublishPost(t *testing.T, expectedBody string, message interface{}) {
func AssertSuccessPublishPost(t *testing.T, pn *PubNub, expectedBody string, message interface{}) {
assert := assert.New(t)

opts := newPublishOpts(pubnub, pubnub.ctx)
opts := newPublishOpts(pn, pn.ctx)
opts.Channel = "ch"
opts.Message = message
opts.UsePost = true
Expand All @@ -215,6 +215,7 @@ func AssertSuccessPublishPost(t *testing.T, expectedBody string, message interfa
}

func TestPublishMixedGet(t *testing.T) {
pn := NewPubNub(NewDemoConfig())
type msg struct {
One string `json:"one"`
Two string `json:"two"`
Expand Down Expand Up @@ -270,6 +271,8 @@ func TestPublishMixedGet(t *testing.T) {
}

func TestPublishMixedPost(t *testing.T) {
pn := NewPubNub(NewDemoConfig())

type msg struct {
One string `json:"one"`
Two string `json:"two"`
Expand All @@ -282,16 +285,16 @@ func TestPublishMixedPost(t *testing.T) {
msgMap["two"] = "hey2"
msgMap["three"] = "hey3"

AssertSuccessPublishPost(t, "12", 12)
AssertSuccessPublishPost(t, "\"hey\"", "hey")
AssertSuccessPublishPost(t, "true", true)
AssertSuccessPublishPost(t, "[\"hey1\",\"hey2\",\"hey3\"]",
AssertSuccessPublishPost(t, pn, "12", 12)
AssertSuccessPublishPost(t, pn, "\"hey\"", "hey")
AssertSuccessPublishPost(t, pn, "true", true)
AssertSuccessPublishPost(t, pn, "[\"hey1\",\"hey2\",\"hey3\"]",
[]string{"hey1", "hey2", "hey3"})
AssertSuccessPublishPost(t, "[1,2,3]", []int{1, 2, 3})
AssertSuccessPublishPost(t,
AssertSuccessPublishPost(t, pn, "[1,2,3]", []int{1, 2, 3})
AssertSuccessPublishPost(t, pn,
"{\"one\":\"hey1\",\"two\":\"hey2\",\"three\":\"hey3\"}",
msgStruct)
AssertSuccessPublishPost(t,
AssertSuccessPublishPost(t, pn,
"{\"one\":\"hey1\",\"three\":\"hey3\",\"two\":\"hey2\"}",
msgMap)
}
Expand Down
4 changes: 2 additions & 2 deletions subscription_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func processNonPresencePayload(m *SubscriptionManager, payload subscribeMessage,
m.listenerManager.announceMessageActionsEvent(pnMessageActionsEvent)
case PNMessageTypeFile:
var err error
messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.cryptoModule)
messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.getCryptoModule())
if err != nil {
pnStatus := &PNStatus{
Category: PNBadRequestCategory,
Expand All @@ -680,7 +680,7 @@ func processNonPresencePayload(m *SubscriptionManager, payload subscribeMessage,
m.listenerManager.announceFile(pnFilesEvent)
default:
var err error
messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.cryptoModule)
messagePayload, err = parseCipherInterface(payload.Payload, m.pubnub.Config, m.pubnub.getCryptoModule())
if err != nil {
pnStatus := &PNStatus{
Category: PNBadRequestCategory,
Expand Down

0 comments on commit 95f655f

Please sign in to comment.