|
677 | 677 |
|
678 | 678 | context "A restricted epub" do
|
679 | 679 | let(:valid_share_token) do
|
680 |
| - JsonWebToken.encode(data: file_set.id, exp: Time.now.to_i + 48 * 3600) |
| 680 | + JsonWebToken.encode(data: monograph.id, exp: Time.now.to_i + 28 * 24 * 3600) |
681 | 681 | end
|
682 | 682 | let(:expired_share_token) do
|
683 |
| - JsonWebToken.encode(data: file_set.id, exp: Time.now.to_i - 1000) |
| 683 | + JsonWebToken.encode(data: monograph.id, exp: Time.now.to_i - 1000) |
684 | 684 | end
|
685 | 685 | let(:wrong_share_token) do
|
686 |
| - JsonWebToken.encode(data: 'wrongnoid', exp: Time.now.to_i + 48 * 3600) |
| 686 | + JsonWebToken.encode(data: 'wrongnoid', exp: Time.now.to_i + 28 * 24 * 3600) |
687 | 687 | end
|
688 | 688 | let(:parent) { Sighrax.from_noid(monograph.id) }
|
689 | 689 | let(:epub) { Sighrax.from_noid(file_set.id) }
|
|
701 | 701 | expect(ShareLinkLog.last.action).to eq 'use'
|
702 | 702 | expect(ShareLinkLog.last.user).to be_nil
|
703 | 703 | expect(ShareLinkLog.last.title).to eq monograph.title.first
|
704 |
| - expect(ShareLinkLog.last.noid).to eq file_set.id |
| 704 | + expect(ShareLinkLog.last.noid).to eq monograph.id |
705 | 705 | expect(ShareLinkLog.last.token).to eq valid_share_token
|
706 | 706 | end
|
707 | 707 |
|
|
735 | 735 | expect(ShareLinkLog.last.action).to eq 'use'
|
736 | 736 | expect(ShareLinkLog.last.user).to eq user.email
|
737 | 737 | expect(ShareLinkLog.last.title).to eq monograph.title.first
|
738 |
| - expect(ShareLinkLog.last.noid).to eq file_set.id |
| 738 | + expect(ShareLinkLog.last.noid).to eq monograph.id |
739 | 739 | expect(ShareLinkLog.last.token).to eq valid_share_token
|
740 | 740 | end
|
741 | 741 |
|
|
793 | 793 | it 'returns a share link with a valid JSON webtoken and logs the creation' do
|
794 | 794 | get :share_link, params: { id: '222222222' }
|
795 | 795 | expect(response).to have_http_status(:success)
|
796 |
| - expect(response.body).to eq "http://test.host/epubs/222222222?share=#{JsonWebToken.encode(data: '222222222', exp: now.to_i + share_link_expiration_time)}" |
| 796 | + expect(response.body).to eq "http://test.host/epubs/222222222?share=#{JsonWebToken.encode(data: '111111111', exp: now.to_i + share_link_expiration_time)}" |
797 | 797 | expect(ShareLinkLog.count).to eq 1
|
798 | 798 | expect(ShareLinkLog.last.action).to eq 'create'
|
799 | 799 | end
|
|
0 commit comments