mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-13 01:55:42 -05:00
Add some spec coverage (#40306)
This commit is contained in:
@@ -4,7 +4,7 @@ require 'rails_helper'
|
||||
|
||||
RSpec.describe PrivateAddressCheck do
|
||||
describe 'private_address?' do
|
||||
let(:private_ips) { %w(192.168.1.7 0.0.0.0 127.0.0.1 ::ffff:0.0.0.1) }
|
||||
let(:private_ips) { %w(192.168.1.7 0.0.0.0 127.0.0.1 ::ffff:0.0.0.1 ::127.0.0.1 ::ffff:127.0.0.1 ::ffff:10.0.0.1 ::ffff:169.254.169.254 ::) }
|
||||
|
||||
it 'returns true for private addresses' do
|
||||
expect(private_ips)
|
||||
|
||||
@@ -162,6 +162,46 @@ RSpec.describe ActivityPub::ProcessActivityService do
|
||||
expect(ActivityPub::Activity).to_not have_received(:factory)
|
||||
end
|
||||
|
||||
context 'when receiving a status with an unsupported JSON-LD keyword' do
|
||||
let(:payload) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: 'foo',
|
||||
type: 'Announce',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(actor),
|
||||
'@reverse': {
|
||||
object: {
|
||||
type: 'Undo',
|
||||
id: 'bar',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(actor),
|
||||
},
|
||||
},
|
||||
object: {
|
||||
id: 'bar',
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
},
|
||||
signature: {
|
||||
type: 'RsaSignature2017',
|
||||
creator: "#{ActivityPub::TagManager.instance.uri_for(actor)}#foo",
|
||||
created: '2022-03-09T21:57:25Z',
|
||||
signatureValue: 'foo',
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not process payload' do
|
||||
signature_double = instance_double(ActivityPub::LinkedDataSignature, verify_actor!: nil)
|
||||
allow(ActivityPub::LinkedDataSignature).to receive(:new).and_return(signature_double)
|
||||
allow(ActivityPub::Activity).to receive(:factory)
|
||||
|
||||
subject.call(json, forwarder)
|
||||
|
||||
expect(signature_double).to_not have_received(:verify_actor!)
|
||||
expect(ActivityPub::Activity).to_not have_received(:factory)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when receiving a fabricated status' do
|
||||
let!(:actor) do
|
||||
Fabricate(:account,
|
||||
|
||||
25
spec/validators/email_address_validator_spec.rb
Normal file
25
spec/validators/email_address_validator_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EmailAddressValidator do
|
||||
subject { record_class.new }
|
||||
|
||||
context 'with no options' do
|
||||
let(:record_class) do
|
||||
Class.new do
|
||||
include ActiveModel::Validations
|
||||
|
||||
def self.name = 'Record'
|
||||
|
||||
attr_accessor :email
|
||||
|
||||
validates :email, email_address: true
|
||||
end
|
||||
end
|
||||
|
||||
it { is_expected.to allow_value('foo@example.com').for(:email) }
|
||||
it { is_expected.to_not allow_value('foo @ example.com').for(:email) }
|
||||
it { is_expected.to_not allow_value('foo@example.com%foo.example.com').for(:email) }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user