Slightly reduce RAM usage (#7301)
* No need to re-require sidekiq plugins, they are required via Gemfile * Add derailed_benchmarks tool, no need to require TTY gems in Gemfile * Replace ruby-oembed with FetchOEmbedService Reduce startup by 45382 allocated objects * Remove preloaded JSON-LD in favour of caching HTTP responses Reduce boot RAM by about 6 MiB * Fix tests * Fix test suite by stubbing out JSON-LD contexts
This commit is contained in:
parent
71a7cea73f
commit
cb5b5cb5f7
76 changed files with 784 additions and 471 deletions
391
spec/fixtures/requests/json-ld.activitystreams.txt
vendored
Normal file
391
spec/fixtures/requests/json-ld.activitystreams.txt
vendored
Normal file
|
@ -0,0 +1,391 @@
|
|||
HTTP/1.1 200 OK
|
||||
Date: Tue, 01 May 2018 23:25:57 GMT
|
||||
Content-Location: activitystreams.jsonld
|
||||
Vary: negotiate,accept
|
||||
TCN: choice
|
||||
Last-Modified: Mon, 16 Apr 2018 00:28:23 GMT
|
||||
ETag: "1eb0-569ec4caa97c0;d3-540ee27e0eec0"
|
||||
Accept-Ranges: bytes
|
||||
Content-Length: 7856
|
||||
Cache-Control: max-age=21600
|
||||
Expires: Wed, 02 May 2018 05:25:57 GMT
|
||||
P3P: policyref="http://www.w3.org/2014/08/p3p.xml"
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/ld+json
|
||||
Strict-Transport-Security: max-age=15552000; includeSubdomains; preload
|
||||
Content-Security-Policy: upgrade-insecure-requests
|
||||
|
||||
{
|
||||
"@context": {
|
||||
"@vocab": "_:",
|
||||
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
||||
"as": "https://www.w3.org/ns/activitystreams#",
|
||||
"ldp": "http://www.w3.org/ns/ldp#",
|
||||
"id": "@id",
|
||||
"type": "@type",
|
||||
"Accept": "as:Accept",
|
||||
"Activity": "as:Activity",
|
||||
"IntransitiveActivity": "as:IntransitiveActivity",
|
||||
"Add": "as:Add",
|
||||
"Announce": "as:Announce",
|
||||
"Application": "as:Application",
|
||||
"Arrive": "as:Arrive",
|
||||
"Article": "as:Article",
|
||||
"Audio": "as:Audio",
|
||||
"Block": "as:Block",
|
||||
"Collection": "as:Collection",
|
||||
"CollectionPage": "as:CollectionPage",
|
||||
"Relationship": "as:Relationship",
|
||||
"Create": "as:Create",
|
||||
"Delete": "as:Delete",
|
||||
"Dislike": "as:Dislike",
|
||||
"Document": "as:Document",
|
||||
"Event": "as:Event",
|
||||
"Follow": "as:Follow",
|
||||
"Flag": "as:Flag",
|
||||
"Group": "as:Group",
|
||||
"Ignore": "as:Ignore",
|
||||
"Image": "as:Image",
|
||||
"Invite": "as:Invite",
|
||||
"Join": "as:Join",
|
||||
"Leave": "as:Leave",
|
||||
"Like": "as:Like",
|
||||
"Link": "as:Link",
|
||||
"Mention": "as:Mention",
|
||||
"Note": "as:Note",
|
||||
"Object": "as:Object",
|
||||
"Offer": "as:Offer",
|
||||
"OrderedCollection": "as:OrderedCollection",
|
||||
"OrderedCollectionPage": "as:OrderedCollectionPage",
|
||||
"Organization": "as:Organization",
|
||||
"Page": "as:Page",
|
||||
"Person": "as:Person",
|
||||
"Place": "as:Place",
|
||||
"Profile": "as:Profile",
|
||||
"Question": "as:Question",
|
||||
"Reject": "as:Reject",
|
||||
"Remove": "as:Remove",
|
||||
"Service": "as:Service",
|
||||
"TentativeAccept": "as:TentativeAccept",
|
||||
"TentativeReject": "as:TentativeReject",
|
||||
"Tombstone": "as:Tombstone",
|
||||
"Undo": "as:Undo",
|
||||
"Update": "as:Update",
|
||||
"Video": "as:Video",
|
||||
"View": "as:View",
|
||||
"Listen": "as:Listen",
|
||||
"Read": "as:Read",
|
||||
"Move": "as:Move",
|
||||
"Travel": "as:Travel",
|
||||
"IsFollowing": "as:IsFollowing",
|
||||
"IsFollowedBy": "as:IsFollowedBy",
|
||||
"IsContact": "as:IsContact",
|
||||
"IsMember": "as:IsMember",
|
||||
"subject": {
|
||||
"@id": "as:subject",
|
||||
"@type": "@id"
|
||||
},
|
||||
"relationship": {
|
||||
"@id": "as:relationship",
|
||||
"@type": "@id"
|
||||
},
|
||||
"actor": {
|
||||
"@id": "as:actor",
|
||||
"@type": "@id"
|
||||
},
|
||||
"attributedTo": {
|
||||
"@id": "as:attributedTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"attachment": {
|
||||
"@id": "as:attachment",
|
||||
"@type": "@id"
|
||||
},
|
||||
"bcc": {
|
||||
"@id": "as:bcc",
|
||||
"@type": "@id"
|
||||
},
|
||||
"bto": {
|
||||
"@id": "as:bto",
|
||||
"@type": "@id"
|
||||
},
|
||||
"cc": {
|
||||
"@id": "as:cc",
|
||||
"@type": "@id"
|
||||
},
|
||||
"context": {
|
||||
"@id": "as:context",
|
||||
"@type": "@id"
|
||||
},
|
||||
"current": {
|
||||
"@id": "as:current",
|
||||
"@type": "@id"
|
||||
},
|
||||
"first": {
|
||||
"@id": "as:first",
|
||||
"@type": "@id"
|
||||
},
|
||||
"generator": {
|
||||
"@id": "as:generator",
|
||||
"@type": "@id"
|
||||
},
|
||||
"icon": {
|
||||
"@id": "as:icon",
|
||||
"@type": "@id"
|
||||
},
|
||||
"image": {
|
||||
"@id": "as:image",
|
||||
"@type": "@id"
|
||||
},
|
||||
"inReplyTo": {
|
||||
"@id": "as:inReplyTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"items": {
|
||||
"@id": "as:items",
|
||||
"@type": "@id"
|
||||
},
|
||||
"instrument": {
|
||||
"@id": "as:instrument",
|
||||
"@type": "@id"
|
||||
},
|
||||
"orderedItems": {
|
||||
"@id": "as:items",
|
||||
"@type": "@id",
|
||||
"@container": "@list"
|
||||
},
|
||||
"last": {
|
||||
"@id": "as:last",
|
||||
"@type": "@id"
|
||||
},
|
||||
"location": {
|
||||
"@id": "as:location",
|
||||
"@type": "@id"
|
||||
},
|
||||
"next": {
|
||||
"@id": "as:next",
|
||||
"@type": "@id"
|
||||
},
|
||||
"object": {
|
||||
"@id": "as:object",
|
||||
"@type": "@id"
|
||||
},
|
||||
"oneOf": {
|
||||
"@id": "as:oneOf",
|
||||
"@type": "@id"
|
||||
},
|
||||
"anyOf": {
|
||||
"@id": "as:anyOf",
|
||||
"@type": "@id"
|
||||
},
|
||||
"closed": {
|
||||
"@id": "as:closed",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"origin": {
|
||||
"@id": "as:origin",
|
||||
"@type": "@id"
|
||||
},
|
||||
"accuracy": {
|
||||
"@id": "as:accuracy",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"prev": {
|
||||
"@id": "as:prev",
|
||||
"@type": "@id"
|
||||
},
|
||||
"preview": {
|
||||
"@id": "as:preview",
|
||||
"@type": "@id"
|
||||
},
|
||||
"replies": {
|
||||
"@id": "as:replies",
|
||||
"@type": "@id"
|
||||
},
|
||||
"result": {
|
||||
"@id": "as:result",
|
||||
"@type": "@id"
|
||||
},
|
||||
"audience": {
|
||||
"@id": "as:audience",
|
||||
"@type": "@id"
|
||||
},
|
||||
"partOf": {
|
||||
"@id": "as:partOf",
|
||||
"@type": "@id"
|
||||
},
|
||||
"tag": {
|
||||
"@id": "as:tag",
|
||||
"@type": "@id"
|
||||
},
|
||||
"target": {
|
||||
"@id": "as:target",
|
||||
"@type": "@id"
|
||||
},
|
||||
"to": {
|
||||
"@id": "as:to",
|
||||
"@type": "@id"
|
||||
},
|
||||
"url": {
|
||||
"@id": "as:url",
|
||||
"@type": "@id"
|
||||
},
|
||||
"altitude": {
|
||||
"@id": "as:altitude",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"content": "as:content",
|
||||
"contentMap": {
|
||||
"@id": "as:content",
|
||||
"@container": "@language"
|
||||
},
|
||||
"name": "as:name",
|
||||
"nameMap": {
|
||||
"@id": "as:name",
|
||||
"@container": "@language"
|
||||
},
|
||||
"duration": {
|
||||
"@id": "as:duration",
|
||||
"@type": "xsd:duration"
|
||||
},
|
||||
"endTime": {
|
||||
"@id": "as:endTime",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"height": {
|
||||
"@id": "as:height",
|
||||
"@type": "xsd:nonNegativeInteger"
|
||||
},
|
||||
"href": {
|
||||
"@id": "as:href",
|
||||
"@type": "@id"
|
||||
},
|
||||
"hreflang": "as:hreflang",
|
||||
"latitude": {
|
||||
"@id": "as:latitude",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"longitude": {
|
||||
"@id": "as:longitude",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"mediaType": "as:mediaType",
|
||||
"published": {
|
||||
"@id": "as:published",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"radius": {
|
||||
"@id": "as:radius",
|
||||
"@type": "xsd:float"
|
||||
},
|
||||
"rel": "as:rel",
|
||||
"startIndex": {
|
||||
"@id": "as:startIndex",
|
||||
"@type": "xsd:nonNegativeInteger"
|
||||
},
|
||||
"startTime": {
|
||||
"@id": "as:startTime",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"summary": "as:summary",
|
||||
"summaryMap": {
|
||||
"@id": "as:summary",
|
||||
"@container": "@language"
|
||||
},
|
||||
"totalItems": {
|
||||
"@id": "as:totalItems",
|
||||
"@type": "xsd:nonNegativeInteger"
|
||||
},
|
||||
"units": "as:units",
|
||||
"updated": {
|
||||
"@id": "as:updated",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"width": {
|
||||
"@id": "as:width",
|
||||
"@type": "xsd:nonNegativeInteger"
|
||||
},
|
||||
"describes": {
|
||||
"@id": "as:describes",
|
||||
"@type": "@id"
|
||||
},
|
||||
"formerType": {
|
||||
"@id": "as:formerType",
|
||||
"@type": "@id"
|
||||
},
|
||||
"deleted": {
|
||||
"@id": "as:deleted",
|
||||
"@type": "xsd:dateTime"
|
||||
},
|
||||
"inbox": {
|
||||
"@id": "ldp:inbox",
|
||||
"@type": "@id"
|
||||
},
|
||||
"outbox": {
|
||||
"@id": "as:outbox",
|
||||
"@type": "@id"
|
||||
},
|
||||
"following": {
|
||||
"@id": "as:following",
|
||||
"@type": "@id"
|
||||
},
|
||||
"followers": {
|
||||
"@id": "as:followers",
|
||||
"@type": "@id"
|
||||
},
|
||||
"streams": {
|
||||
"@id": "as:streams",
|
||||
"@type": "@id"
|
||||
},
|
||||
"preferredUsername": "as:preferredUsername",
|
||||
"endpoints": {
|
||||
"@id": "as:endpoints",
|
||||
"@type": "@id"
|
||||
},
|
||||
"uploadMedia": {
|
||||
"@id": "as:uploadMedia",
|
||||
"@type": "@id"
|
||||
},
|
||||
"proxyUrl": {
|
||||
"@id": "as:proxyUrl",
|
||||
"@type": "@id"
|
||||
},
|
||||
"liked": {
|
||||
"@id": "as:liked",
|
||||
"@type": "@id"
|
||||
},
|
||||
"oauthAuthorizationEndpoint": {
|
||||
"@id": "as:oauthAuthorizationEndpoint",
|
||||
"@type": "@id"
|
||||
},
|
||||
"oauthTokenEndpoint": {
|
||||
"@id": "as:oauthTokenEndpoint",
|
||||
"@type": "@id"
|
||||
},
|
||||
"provideClientKey": {
|
||||
"@id": "as:provideClientKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"signClientKey": {
|
||||
"@id": "as:signClientKey",
|
||||
"@type": "@id"
|
||||
},
|
||||
"sharedInbox": {
|
||||
"@id": "as:sharedInbox",
|
||||
"@type": "@id"
|
||||
},
|
||||
"Public": {
|
||||
"@id": "as:Public",
|
||||
"@type": "@id"
|
||||
},
|
||||
"source": "as:source",
|
||||
"likes": {
|
||||
"@id": "as:likes",
|
||||
"@type": "@id"
|
||||
},
|
||||
"shares": {
|
||||
"@id": "as:shares",
|
||||
"@type": "@id"
|
||||
}
|
||||
}
|
||||
}
|
100
spec/fixtures/requests/json-ld.identity.txt
vendored
Normal file
100
spec/fixtures/requests/json-ld.identity.txt
vendored
Normal file
|
@ -0,0 +1,100 @@
|
|||
HTTP/1.1 200 OK
|
||||
Accept-Ranges: bytes
|
||||
Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Encoding
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/ld+json
|
||||
Date: Tue, 01 May 2018 23:28:21 GMT
|
||||
Etag: "e26-547a6fc75b04a-gzip"
|
||||
Last-Modified: Fri, 03 Feb 2017 21:30:09 GMT
|
||||
Server: Apache/2.4.7 (Ubuntu)
|
||||
Vary: Accept-Encoding
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
{
|
||||
"@context": {
|
||||
"id": "@id",
|
||||
"type": "@type",
|
||||
|
||||
"cred": "https://w3id.org/credentials#",
|
||||
"dc": "http://purl.org/dc/terms/",
|
||||
"identity": "https://w3id.org/identity#",
|
||||
"perm": "https://w3id.org/permissions#",
|
||||
"ps": "https://w3id.org/payswarm#",
|
||||
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
||||
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
|
||||
"sec": "https://w3id.org/security#",
|
||||
"schema": "http://schema.org/",
|
||||
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
||||
|
||||
"Group": "https://www.w3.org/ns/activitystreams#Group",
|
||||
|
||||
"claim": {"@id": "cred:claim", "@type": "@id"},
|
||||
"credential": {"@id": "cred:credential", "@type": "@id"},
|
||||
"issued": {"@id": "cred:issued", "@type": "xsd:dateTime"},
|
||||
"issuer": {"@id": "cred:issuer", "@type": "@id"},
|
||||
"recipient": {"@id": "cred:recipient", "@type": "@id"},
|
||||
"Credential": "cred:Credential",
|
||||
"CryptographicKeyCredential": "cred:CryptographicKeyCredential",
|
||||
|
||||
"about": {"@id": "schema:about", "@type": "@id"},
|
||||
"address": {"@id": "schema:address", "@type": "@id"},
|
||||
"addressCountry": "schema:addressCountry",
|
||||
"addressLocality": "schema:addressLocality",
|
||||
"addressRegion": "schema:addressRegion",
|
||||
"comment": "rdfs:comment",
|
||||
"created": {"@id": "dc:created", "@type": "xsd:dateTime"},
|
||||
"creator": {"@id": "dc:creator", "@type": "@id"},
|
||||
"description": "schema:description",
|
||||
"email": "schema:email",
|
||||
"familyName": "schema:familyName",
|
||||
"givenName": "schema:givenName",
|
||||
"image": {"@id": "schema:image", "@type": "@id"},
|
||||
"label": "rdfs:label",
|
||||
"name": "schema:name",
|
||||
"postalCode": "schema:postalCode",
|
||||
"streetAddress": "schema:streetAddress",
|
||||
"title": "dc:title",
|
||||
"url": {"@id": "schema:url", "@type": "@id"},
|
||||
"Person": "schema:Person",
|
||||
"PostalAddress": "schema:PostalAddress",
|
||||
"Organization": "schema:Organization",
|
||||
|
||||
"identityService": {"@id": "identity:identityService", "@type": "@id"},
|
||||
"idp": {"@id": "identity:idp", "@type": "@id"},
|
||||
"Identity": "identity:Identity",
|
||||
|
||||
"paymentProcessor": "ps:processor",
|
||||
"preferences": {"@id": "ps:preferences", "@type": "@vocab"},
|
||||
|
||||
"cipherAlgorithm": "sec:cipherAlgorithm",
|
||||
"cipherData": "sec:cipherData",
|
||||
"cipherKey": "sec:cipherKey",
|
||||
"digestAlgorithm": "sec:digestAlgorithm",
|
||||
"digestValue": "sec:digestValue",
|
||||
"domain": "sec:domain",
|
||||
"expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
|
||||
"initializationVector": "sec:initializationVector",
|
||||
"member": {"@id": "schema:member", "@type": "@id"},
|
||||
"memberOf": {"@id": "schema:memberOf", "@type": "@id"},
|
||||
"nonce": "sec:nonce",
|
||||
"normalizationAlgorithm": "sec:normalizationAlgorithm",
|
||||
"owner": {"@id": "sec:owner", "@type": "@id"},
|
||||
"password": "sec:password",
|
||||
"privateKey": {"@id": "sec:privateKey", "@type": "@id"},
|
||||
"privateKeyPem": "sec:privateKeyPem",
|
||||
"publicKey": {"@id": "sec:publicKey", "@type": "@id"},
|
||||
"publicKeyPem": "sec:publicKeyPem",
|
||||
"publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"},
|
||||
"revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"},
|
||||
"signature": "sec:signature",
|
||||
"signatureAlgorithm": "sec:signatureAlgorithm",
|
||||
"signatureValue": "sec:signatureValue",
|
||||
"CryptographicKey": "sec:Key",
|
||||
"EncryptedMessage": "sec:EncryptedMessage",
|
||||
"GraphSignature2012": "sec:GraphSignature2012",
|
||||
"LinkedDataSignature2015": "sec:LinkedDataSignature2015",
|
||||
|
||||
"accessControl": {"@id": "perm:accessControl", "@type": "@id"},
|
||||
"writePermission": {"@id": "perm:writePermission", "@type": "@id"}
|
||||
}
|
||||
}
|
61
spec/fixtures/requests/json-ld.security.txt
vendored
Normal file
61
spec/fixtures/requests/json-ld.security.txt
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
HTTP/1.1 200 OK
|
||||
Accept-Ranges: bytes
|
||||
Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Encoding
|
||||
Access-Control-Allow-Origin: *
|
||||
Content-Type: application/ld+json
|
||||
Date: Wed, 02 May 2018 16:25:32 GMT
|
||||
Etag: "7e3-5651ec0f7c5ed-gzip"
|
||||
Last-Modified: Tue, 13 Feb 2018 21:34:04 GMT
|
||||
Server: Apache/2.4.7 (Ubuntu)
|
||||
Vary: Accept-Encoding
|
||||
Content-Length: 2019
|
||||
|
||||
{
|
||||
"@context": {
|
||||
"id": "@id",
|
||||
"type": "@type",
|
||||
|
||||
"dc": "http://purl.org/dc/terms/",
|
||||
"sec": "https://w3id.org/security#",
|
||||
"xsd": "http://www.w3.org/2001/XMLSchema#",
|
||||
|
||||
"EcdsaKoblitzSignature2016": "sec:EcdsaKoblitzSignature2016",
|
||||
"Ed25519Signature2018": "sec:Ed25519Signature2018",
|
||||
"EncryptedMessage": "sec:EncryptedMessage",
|
||||
"GraphSignature2012": "sec:GraphSignature2012",
|
||||
"LinkedDataSignature2015": "sec:LinkedDataSignature2015",
|
||||
"LinkedDataSignature2016": "sec:LinkedDataSignature2016",
|
||||
"CryptographicKey": "sec:Key",
|
||||
|
||||
"authenticationTag": "sec:authenticationTag",
|
||||
"canonicalizationAlgorithm": "sec:canonicalizationAlgorithm",
|
||||
"cipherAlgorithm": "sec:cipherAlgorithm",
|
||||
"cipherData": "sec:cipherData",
|
||||
"cipherKey": "sec:cipherKey",
|
||||
"created": {"@id": "dc:created", "@type": "xsd:dateTime"},
|
||||
"creator": {"@id": "dc:creator", "@type": "@id"},
|
||||
"digestAlgorithm": "sec:digestAlgorithm",
|
||||
"digestValue": "sec:digestValue",
|
||||
"domain": "sec:domain",
|
||||
"encryptionKey": "sec:encryptionKey",
|
||||
"expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
|
||||
"expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"},
|
||||
"initializationVector": "sec:initializationVector",
|
||||
"iterationCount": "sec:iterationCount",
|
||||
"nonce": "sec:nonce",
|
||||
"normalizationAlgorithm": "sec:normalizationAlgorithm",
|
||||
"owner": {"@id": "sec:owner", "@type": "@id"},
|
||||
"password": "sec:password",
|
||||
"privateKey": {"@id": "sec:privateKey", "@type": "@id"},
|
||||
"privateKeyPem": "sec:privateKeyPem",
|
||||
"publicKey": {"@id": "sec:publicKey", "@type": "@id"},
|
||||
"publicKeyBase58": "sec:publicKeyBase58",
|
||||
"publicKeyPem": "sec:publicKeyPem",
|
||||
"publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"},
|
||||
"revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"},
|
||||
"salt": "sec:salt",
|
||||
"signature": "sec:signature",
|
||||
"signatureAlgorithm": "sec:signingAlgorithm",
|
||||
"signatureValue": "sec:signatureValue"
|
||||
}
|
||||
}
|
|
@ -16,6 +16,10 @@ RSpec.describe ActivityPub::LinkedDataSignature do
|
|||
|
||||
subject { described_class.new(json) }
|
||||
|
||||
before do
|
||||
stub_jsonld_contexts!
|
||||
end
|
||||
|
||||
describe '#verify_account!' do
|
||||
context 'when signature matches' do
|
||||
let(:raw_signature) do
|
||||
|
|
|
@ -50,6 +50,14 @@ RSpec.configure do |config|
|
|||
Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}"
|
||||
end
|
||||
|
||||
config.before :each, type: :controller do
|
||||
stub_jsonld_contexts!
|
||||
end
|
||||
|
||||
config.before :each, type: :service do
|
||||
stub_jsonld_contexts!
|
||||
end
|
||||
|
||||
config.after :each do
|
||||
Rails.cache.clear
|
||||
|
||||
|
@ -69,3 +77,9 @@ end
|
|||
def attachment_fixture(name)
|
||||
File.open(File.join(Rails.root, 'spec', 'fixtures', 'files', name))
|
||||
end
|
||||
|
||||
def stub_jsonld_contexts!
|
||||
stub_request(:get, 'https://www.w3.org/ns/activitystreams').to_return(request_fixture('json-ld.activitystreams.txt'))
|
||||
stub_request(:get, 'https://w3id.org/identity/v1').to_return(request_fixture('json-ld.identity.txt'))
|
||||
stub_request(:get, 'https://w3id.org/security/v1').to_return(request_fixture('json-ld.security.txt'))
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe AccountSearchService do
|
||||
describe AccountSearchService, type: :service do
|
||||
describe '.call' do
|
||||
describe 'with a query to ignore' do
|
||||
it 'returns empty array for missing query' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
||||
subject { ActivityPub::FetchRemoteAccountService.new }
|
||||
|
||||
let!(:actor) do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
let(:sender) { Fabricate(:account) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::ProcessAccountService do
|
||||
RSpec.describe ActivityPub::ProcessAccountService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
context 'property values' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::ProcessCollectionService do
|
||||
RSpec.describe ActivityPub::ProcessCollectionService, type: :service do
|
||||
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') }
|
||||
|
||||
let(:payload) do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AfterBlockService do
|
||||
RSpec.describe AfterBlockService, type: :service do
|
||||
subject do
|
||||
-> { described_class.new.call(account, target_account) }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AuthorizeFollowService do
|
||||
RSpec.describe AuthorizeFollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { AuthorizeFollowService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BatchedRemoveStatusService do
|
||||
RSpec.describe BatchedRemoveStatusService, type: :service do
|
||||
subject { BatchedRemoveStatusService.new }
|
||||
|
||||
let!(:alice) { Fabricate(:account) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BlockDomainFromAccountService do
|
||||
RSpec.describe BlockDomainFromAccountService, type: :service do
|
||||
let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org') }
|
||||
let!(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BlockDomainService do
|
||||
RSpec.describe BlockDomainService, type: :service do
|
||||
let(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') }
|
||||
let(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') }
|
||||
let(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BlockService do
|
||||
RSpec.describe BlockService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { BlockService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BootstrapTimelineService do
|
||||
RSpec.describe BootstrapTimelineService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FanOutOnWriteService do
|
||||
RSpec.describe FanOutOnWriteService, type: :service do
|
||||
let(:author) { Fabricate(:account, username: 'tom') }
|
||||
let(:status) { Fabricate(:status, text: 'Hello @alice #test', account: author) }
|
||||
let(:alice) { Fabricate(:user, account: Fabricate(:account, username: 'alice')).account }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FavouriteService do
|
||||
RSpec.describe FavouriteService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { FavouriteService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchAtomService do
|
||||
RSpec.describe FetchAtomService, type: :service do
|
||||
describe '#call' do
|
||||
let(:url) { 'http://example.com' }
|
||||
subject { FetchAtomService.new.call(url) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchLinkCardService do
|
||||
RSpec.describe FetchLinkCardService, type: :service do
|
||||
subject { FetchLinkCardService.new }
|
||||
|
||||
before do
|
||||
|
|
|
@ -2,7 +2,14 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ProviderDiscovery do
|
||||
describe FetchOEmbedService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
before do
|
||||
stub_request(:get, "https://host.test/provider.json").to_return(status: 404)
|
||||
stub_request(:get, "https://host.test/provider.xml").to_return(status: 404)
|
||||
end
|
||||
|
||||
describe 'discover_provider' do
|
||||
context 'when status code is 200 and MIME type is text/html' do
|
||||
context 'Both of JSON and XML provider are discoverable' do
|
||||
|
@ -15,15 +22,15 @@ describe ProviderDiscovery do
|
|||
end
|
||||
|
||||
it 'returns new OEmbed::Provider for JSON provider if :format option is set to :json' do
|
||||
provider = ProviderDiscovery.discover_provider('https://host.test/oembed.html', format: :json)
|
||||
expect(provider.endpoint).to eq 'https://host.test/provider.json'
|
||||
expect(provider.format).to eq :json
|
||||
subject.call('https://host.test/oembed.html', format: :json)
|
||||
expect(subject.endpoint_url).to eq 'https://host.test/provider.json'
|
||||
expect(subject.format).to eq :json
|
||||
end
|
||||
|
||||
it 'returns new OEmbed::Provider for XML provider if :format option is set to :xml' do
|
||||
provider = ProviderDiscovery.discover_provider('https://host.test/oembed.html', format: :xml)
|
||||
expect(provider.endpoint).to eq 'https://host.test/provider.xml'
|
||||
expect(provider.format).to eq :xml
|
||||
subject.call('https://host.test/oembed.html', format: :xml)
|
||||
expect(subject.endpoint_url).to eq 'https://host.test/provider.xml'
|
||||
expect(subject.format).to eq :xml
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,9 +44,9 @@ describe ProviderDiscovery do
|
|||
end
|
||||
|
||||
it 'returns new OEmbed::Provider for JSON provider' do
|
||||
provider = ProviderDiscovery.discover_provider('https://host.test/oembed.html')
|
||||
expect(provider.endpoint).to eq 'https://host.test/provider.json'
|
||||
expect(provider.format).to eq :json
|
||||
subject.call('https://host.test/oembed.html')
|
||||
expect(subject.endpoint_url).to eq 'https://host.test/provider.json'
|
||||
expect(subject.format).to eq :json
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -53,9 +60,9 @@ describe ProviderDiscovery do
|
|||
end
|
||||
|
||||
it 'returns new OEmbed::Provider for XML provider' do
|
||||
provider = ProviderDiscovery.discover_provider('https://host.test/oembed.html')
|
||||
expect(provider.endpoint).to eq 'https://host.test/provider.xml'
|
||||
expect(provider.format).to eq :xml
|
||||
subject.call('https://host.test/oembed.html')
|
||||
expect(subject.endpoint_url).to eq 'https://host.test/provider.xml'
|
||||
expect(subject.format).to eq :xml
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -68,8 +75,8 @@ describe ProviderDiscovery do
|
|||
)
|
||||
end
|
||||
|
||||
it 'raises OEmbed::NotFound' do
|
||||
expect { ProviderDiscovery.discover_provider('https://host.test/oembed.html') }.to raise_error OEmbed::NotFound
|
||||
it 'returns nil' do
|
||||
expect(subject.call('https://host.test/oembed.html')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -82,8 +89,8 @@ describe ProviderDiscovery do
|
|||
)
|
||||
end
|
||||
|
||||
it 'raises OEmbed::NotFound' do
|
||||
expect { ProviderDiscovery.discover_provider('https://host.test/oembed.html') }.to raise_error OEmbed::NotFound
|
||||
it 'returns nil' do
|
||||
expect(subject.call('https://host.test/oembed.html')).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -97,8 +104,8 @@ describe ProviderDiscovery do
|
|||
)
|
||||
end
|
||||
|
||||
it 'raises OEmbed::NotFound' do
|
||||
expect { ProviderDiscovery.discover_provider('https://host.test/oembed.html') }.to raise_error OEmbed::NotFound
|
||||
it 'returns nil' do
|
||||
expect(subject.call('https://host.test/oembed.html')).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,8 +117,8 @@ describe ProviderDiscovery do
|
|||
)
|
||||
end
|
||||
|
||||
it 'raises OEmbed::NotFound' do
|
||||
expect { ProviderDiscovery.discover_provider('https://host.test/oembed.html') }.to raise_error OEmbed::NotFound
|
||||
it 'returns nil' do
|
||||
expect(subject.call('https://host.test/oembed.html')).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchRemoteAccountService do
|
||||
RSpec.describe FetchRemoteAccountService, type: :service do
|
||||
let(:url) { 'https://example.com' }
|
||||
let(:prefetched_body) { nil }
|
||||
let(:protocol) { :ostatus }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FetchRemoteStatusService do
|
||||
RSpec.describe FetchRemoteStatusService, type: :service do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:prefetched_body) { nil }
|
||||
let(:valid_domain) { Rails.configuration.x.local_domain }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe FollowService do
|
||||
RSpec.describe FollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { FollowService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe MuteService do
|
||||
RSpec.describe MuteService, type: :service do
|
||||
subject do
|
||||
-> { described_class.new.call(account, target_account) }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe NotifyService do
|
||||
RSpec.describe NotifyService, type: :service do
|
||||
subject do
|
||||
-> { described_class.new.call(recipient, activity) }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PostStatusService do
|
||||
RSpec.describe PostStatusService, type: :service do
|
||||
subject { PostStatusService.new }
|
||||
|
||||
it 'creates a new status' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe PrecomputeFeedService do
|
||||
RSpec.describe PrecomputeFeedService, type: :service do
|
||||
subject { PrecomputeFeedService.new }
|
||||
|
||||
describe 'call' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessFeedService do
|
||||
RSpec.describe ProcessFeedService, type: :service do
|
||||
subject { ProcessFeedService.new }
|
||||
|
||||
describe 'processing a feed' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessInteractionService do
|
||||
RSpec.describe ProcessInteractionService, type: :service do
|
||||
let(:receiver) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account }
|
||||
let(:sender) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
|
||||
let(:remote_sender) { Fabricate(:account, username: 'carol', domain: 'localdomain.com', uri: 'https://webdomain.com/users/carol') }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ProcessMentionsService do
|
||||
RSpec.describe ProcessMentionsService, type: :service do
|
||||
let(:account) { Fabricate(:account, username: 'alice') }
|
||||
let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}") }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Pubsubhubbub::SubscribeService do
|
||||
describe Pubsubhubbub::SubscribeService, type: :service do
|
||||
describe '#call' do
|
||||
subject { described_class.new }
|
||||
let(:user_account) { Fabricate(:account) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe Pubsubhubbub::UnsubscribeService do
|
||||
describe Pubsubhubbub::UnsubscribeService, type: :service do
|
||||
describe '#call' do
|
||||
subject { described_class.new }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ReblogService do
|
||||
RSpec.describe ReblogService, type: :service do
|
||||
let(:alice) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
context 'OStatus' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RejectFollowService do
|
||||
RSpec.describe RejectFollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { RejectFollowService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RemoveStatusService do
|
||||
RSpec.describe RemoveStatusService, type: :service do
|
||||
subject { RemoveStatusService.new }
|
||||
|
||||
let!(:alice) { Fabricate(:account) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ReportService do
|
||||
RSpec.describe ReportService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
let(:source_account) { Fabricate(:account) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ResolveAccountService do
|
||||
RSpec.describe ResolveAccountService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
before do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe ResolveURLService do
|
||||
describe ResolveURLService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe SearchService do
|
||||
describe SearchService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
describe '#call' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SendInteractionService do
|
||||
RSpec.describe SendInteractionService, type: :service do
|
||||
subject { SendInteractionService.new }
|
||||
|
||||
it 'sends an XML envelope to the Salmon end point of remote user'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SubscribeService do
|
||||
RSpec.describe SubscribeService, type: :service do
|
||||
let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com', hub_url: 'http://hub.example.com') }
|
||||
subject { SubscribeService.new }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SuspendAccountService do
|
||||
RSpec.describe SuspendAccountService, type: :service do
|
||||
describe '#call' do
|
||||
subject do
|
||||
-> { described_class.new.call(account) }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'rails_helper'
|
||||
|
||||
describe UnblockDomainService do
|
||||
describe UnblockDomainService, type: :service do
|
||||
subject { described_class.new }
|
||||
|
||||
describe 'call' do
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnblockService do
|
||||
RSpec.describe UnblockService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { UnblockService.new }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnfollowService do
|
||||
RSpec.describe UnfollowService, type: :service do
|
||||
let(:sender) { Fabricate(:account, username: 'alice') }
|
||||
|
||||
subject { UnfollowService.new }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnmuteService do
|
||||
RSpec.describe UnmuteService, type: :service do
|
||||
subject { UnmuteService.new }
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UnsubscribeService do
|
||||
RSpec.describe UnsubscribeService, type: :service do
|
||||
let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com', hub_url: 'http://hub.example.com') }
|
||||
subject { UnsubscribeService.new }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe UpdateRemoteProfileService do
|
||||
RSpec.describe UpdateRemoteProfileService, type: :service do
|
||||
let(:xml) { File.read(File.join(Rails.root, 'spec', 'fixtures', 'push', 'feed.atom')) }
|
||||
|
||||
subject { UpdateRemoteProfileService.new }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require 'rspec/retry'
|
||||
#require 'rspec/retry'
|
||||
require 'simplecov'
|
||||
|
||||
GC.disable
|
||||
|
@ -12,8 +12,8 @@ end
|
|||
gc_counter = -1
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.verbose_retry = true
|
||||
config.display_try_failure_messages = true
|
||||
#config.verbose_retry = true
|
||||
#config.display_try_failure_messages = true
|
||||
|
||||
config.expect_with :rspec do |expectations|
|
||||
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
||||
|
@ -29,9 +29,9 @@ RSpec.configure do |config|
|
|||
end
|
||||
end
|
||||
|
||||
config.around :each do |ex|
|
||||
ex.run_with_retry retry: 3
|
||||
end
|
||||
#config.around :each do |ex|
|
||||
# ex.run_with_retry retry: 3
|
||||
#end
|
||||
|
||||
config.before :suite do
|
||||
Chewy.strategy(:bypass)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue