Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some happy case specs #3

Merged
merged 1 commit into from
May 12, 2016
Merged

Conversation

waheedel
Copy link
Contributor

No description provided.

@zaru
Copy link
Owner

zaru commented May 11, 2016

@waheedel Thanks for the pull-request. I wanted a test case. so happy!
However, it looks like this test case is not working.

Net::HTTP::Post raise
<Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8>

Random numbers may stub is not used in the cause.

@waheedel
Copy link
Contributor Author

Hey @zaru great work on the gem.

I'm not seeing the error you provided. How are you running the tests?

@zaru
Copy link
Owner

zaru commented May 12, 2016

@waheedel
yes. the test passes all.
but Webpush.payload_send return false.

I can confirm to catch the exception that occurred in the push_server_post.

def push_server_post(endpoint, payload, api_key = "")
  begin
    uri = URI.parse(endpoint)
    # snip
    req = Net::HTTP::Post.new(uri.request_uri, header)
    req.body = payload[:ciphertext]
    res = http.request(req)
    return ("201" == res.code) ? true : false
  rescue => e
    p e # <Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8>
    return false
  end
end

I thought it was because the different req.body and :expected_body.
req.body will change every time run.

I am not familiar with how to use the webmock, please point out if I'm wrong.

@waheedel waheedel force-pushed the wem/happy-case-testing branch from 0b877db to 7d2a47e Compare May 12, 2016 10:28
@waheedel waheedel force-pushed the wem/happy-case-testing branch from 7d2a47e to 87c9d17 Compare May 12, 2016 10:29
@waheedel
Copy link
Contributor Author

You are indeed right. Because we have a random salt the headers that we were expecting changed for each test. I have updated to stub out the encrypt method and return a predefined payload.

@zaru
Copy link
Owner

zaru commented May 12, 2016

merged, very thanks!

@zaru zaru merged commit f3198db into zaru:master May 12, 2016
@waheedel
Copy link
Contributor Author

Thanks @zaru

@waheedel waheedel deleted the wem/happy-case-testing branch May 12, 2016 11:58
zaru pushed a commit that referenced this pull request Aug 15, 2019
changes to use aes128gcm for payload encryption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants