Commit graph

71 commits

Author SHA1 Message Date
Benjamin Neff
32a49cc549
Get optional props from validated object
This is much easier and safer than "guessing" the class name based on
the validator name. That can cause a problem when another class with the
same name is found. The "guessing" was only added because we used
OpenStruct in the tests, but we shouldn't change the code only to make
tests run. I changed the tests to use the real entities, with
auto-validation disabled in the constructor, so we can test the
validator manually.
2018-02-14 01:37:20 +01:00
Benjamin Neff
0ff382248a
Fix warning about shared example group 'a signable' been defined twice 2018-01-22 04:13:45 +01:00
cmrd Senya
69e523abd0 Extract account migration sign feature to a module
This module can be used to compute account migration signature in other
objects besides Entities::AccountMigration. For instance this is to be
used in AccountMigration model of diaspora* web application.
2017-12-27 18:37:48 +02:00
Benjamin Neff
e663a65c7e
Remove not_nil for diaspora IDs from validators
The diaspora ID validator now is not nil by default.

Also:
* mark root_author as optional for reshares.
* make author for profiles mandatory (I don't remember why this was
optional, we never generate a profile without author and we wouldn't
receive a profile without author anyway, because we validate that the
author is the sender).
* refactor validator specs for diaspora IDs
2017-09-12 23:11:05 +02:00
cmrd Senya
5b12afebed
Allow reshares with no root 2017-08-25 10:33:16 +03:00
Benjamin Neff
f5ff4a71e6
Only add optional properties to generated XML and JSON when not nil 2017-07-30 00:32:54 +02:00
Benjamin Neff
e26a86c173
Switch PercentLiteralDelimiters to new default
Let's change that to the new rubocop default, which is also the
suggestion in the ruby style guide.

See https://github.com/bbatsov/ruby-style-guide#percent-literal-braces

This was changed in diaspora too, see diaspora/diaspora#7466

It also includes the changes in the code. This was done with
`rubocop --auto-correct` and no we have zero offenses again.
2017-06-30 02:23:44 +02:00
Benjamin Neff
5b22d04626
Add created_at to comment
Fixes diaspora/diaspora#4269
2017-06-05 23:58:08 +02:00
Benjamin Neff
a05c6fe6d1
Remove parent_author_signature from json 2017-06-02 01:12:01 +02:00
Benjamin Neff
ba01882cb2
Remove generation code for legacy salmon slap from library
Create legacy_helper.rb to still generate old XMLs for the tests.

Related to #30
2017-05-10 02:37:25 +02:00
Benjamin Neff
cd3a7abf4d
Remove sign-code from SignedRetraction and RelayableRetraction
Second step of #27
2017-05-10 02:37:24 +02:00
Benjamin Neff
221d87d7fe
Send unwrapped entities
Remove the <XML><post>...</post></XML> wrapper.

Second step of #28
2017-05-10 02:37:24 +02:00
Benjamin Neff
87033e4cd6
Remove legacy signature ordering
Relayables are now ordered by the order of the properties of the entity.

Related to #26, but still compatible with pods older than 0.6.3.0.
2017-05-10 02:37:22 +02:00
Benjamin Neff
e238edf4ec
Don't use hash.transform_values
It's only available in ruby >= 2.4
2017-04-05 03:37:20 +02:00
Benjamin Neff
e6e9893c1f
Make rspec work without rails dependency 2017-04-05 02:02:04 +02:00
Benjamin Neff
1f067c62a7
Generate default users only once and reset db after each test 2017-04-05 00:36:53 +02:00
Benjamin Neff
696f50f40d
Replace String#indent from activesupport with helper method 2017-04-05 00:36:53 +02:00
Benjamin Neff
40919b4c69
Create change_time helper method
Time#change is an activesupport feature

Also: Use seconds instead of Numeric#minute and Numeric#hour
2017-04-05 00:36:53 +02:00
Benjamin Neff
ccd4b7eceb
Extract helper methods 2017-04-05 00:36:52 +02:00
Benjamin Neff
f8e7b2114f
Remove fixture_builder 2017-04-04 22:14:13 +02:00
Benjamin Neff
7fe7a5da97
Don't generate file fixtures anymore
When we want to test without rails, we can't use the controllers to
generate them.

Also fixes the problem where there is still an old file fixture that
doesn't match the users in the database.
2017-04-04 22:14:13 +02:00
Benjamin Neff
184954e09c
Replace factory_girl with fabrication
factory_girl has activesupport as dependency
2017-04-04 22:14:13 +02:00
cmrd Senya
7cc0112877
Allow empty strings for signatures in JSON relayables 2017-03-31 21:31:27 +03:00
cmrd Senya
c58d076c96
Entity JSON serialization/deserialization feature 2017-03-23 13:55:19 +02:00
cmrd Senya
6e11fb6810 use enriched_properties in Entity#to_h 2017-01-07 22:55:53 +03:00
Benjamin Neff
dd1c16ce91 add types for string properties 2016-12-28 02:43:16 +01:00
Benjamin Neff
7248aaec67 fix rubocop offenses for rubocop 0.44.1 2016-10-14 23:25:59 +02:00
Benjamin Neff
4295237e9e Raise ValidationError if properties are missing 2016-08-21 21:09:12 +02:00
Steffen van Bergerem
e0ab18c0ea
Improve code documentation 2016-07-12 02:08:21 +02:00
Benjamin Neff
d054d42b86 use .to_h instead of Hash[] 2016-06-20 03:59:23 +02:00
Benjamin Neff
c62bede41c message not relayable anymore
receive only from author and ignore signature checking, or from parent
author with valid signature.

see #36
2016-06-17 18:16:40 +02:00
Benjamin Neff
4bde03e2de use RelatedEntity as normal nested entity, but don't add it to xml 2016-06-05 04:13:55 +02:00
Benjamin Neff
4ded6da139 Entity#to_h returns nested entities as hash 2016-05-30 03:22:07 +02:00
Benjamin Neff
38922d5f30 add string representation to entities for better and easier logging 2016-05-15 00:11:04 +02:00
Benjamin Neff
c9d0b978d4 add validators for empty arrays 2016-04-29 03:59:24 +02:00
Benjamin Neff
1d4d3d732d use shorter callback keys for key-callbacks 2016-03-29 02:42:19 +02:00
Benjamin Neff
2db0931ce5 write more tests for retractions 2016-03-29 02:30:43 +02:00
Benjamin Neff
23fc8dc180 use related entity as parent for relayables 2016-03-28 17:46:37 +02:00
Benjamin Neff
ca0a853134 return MagicEnvelope after parsing a Slap 2016-03-21 01:05:13 +01:00
Benjamin Neff
3a83dc97ac use author_id from slap to fetch pubkey in magic-env 2016-03-20 17:16:08 +01:00
Benjamin Neff
d83b6f14f5 create entity fetcher for public entities 2016-03-15 02:17:04 +01:00
Benjamin Neff
57ed20719f add created_at to comment entity
this is a preparation for diaspora/diaspora#4269
2016-03-08 03:08:28 +01:00
Benjamin Neff
823db3ee18 refactoring xml generation
also refactoring `xml_name`
2016-02-18 03:17:08 +01:00
Benjamin Neff
5ebda543a1 change diaspora_id to author
see #29
2016-02-10 03:17:10 +01:00
Benjamin Neff
76f6929668 add unknown xml elements to the xml again 2016-02-06 02:35:26 +01:00
Benjamin Neff
cf5da6e1ab move guid and diaspora_id to Relayable 2016-02-03 01:59:14 +01:00
Benjamin Neff
eb486b2a18 improve dummy app callbacks 2016-02-03 00:47:21 +01:00
Benjamin Neff
b19e1b8e52 move signing logic for relayables to Relayable
refactoring exceptions for relayables
2016-01-31 20:22:51 +01:00
Benjamin Neff
583d567d67 bump rubocop and pronto-rubocop
make some refactorings for new cops
2016-01-19 01:32:22 +01:00
Benjamin Neff
c7f33d7cf4 rename 'pkey' to 'privkey' and 'pubkey' 2016-01-13 02:20:49 +01:00