decidim-bulletin_board 0.12.1 → 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,7 +33,7 @@ module Decidim
33
33
  response = graphql.query do
34
34
  mutation do
35
35
  publishResults(messageId: args[:message_id], signedData: args[:signed_data]) do
36
- election do
36
+ pendingMessage do
37
37
  status
38
38
  end
39
39
  error
@@ -43,7 +43,7 @@ module Decidim
43
43
 
44
44
  return broadcast(:error, response.data.publish_results.error) if response.data.publish_results.error.present?
45
45
 
46
- broadcast(:ok, response.data.publish_results.election)
46
+ broadcast(:ok, response.data.publish_results.pending_message)
47
47
  rescue Graphlient::Errors::ServerError
48
48
  broadcast(:error, "Sorry, something went wrong")
49
49
  end
@@ -101,7 +101,7 @@ module Decidim
101
101
  def publish_results(election_id)
102
102
  publish_results = configure Authority::PublishResults.new(election_id)
103
103
  yield publish_results.message_id if block_given?
104
- publish_results.on(:ok) { |status| return status }
104
+ publish_results.on(:ok) { |pending_message| return pending_message }
105
105
  publish_results.on(:error) { |error_message| raise StandardError, error_message }
106
106
  publish_results.call
107
107
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module BulletinBoard
5
+ # Client to store GraphQL requests to a CSV file instead of sending them to the BulletinBoard
6
+ # It is intended to be used for load testing
7
+ class FileClient < Decidim::BulletinBoard::Client
8
+ def initialize(file_path, config = Decidim::BulletinBoard)
9
+ @settings = Settings.new(config)
10
+ @graphql = Graphql::Factory.client_for_file(settings, file_path)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -310,6 +310,34 @@
310
310
  },
311
311
  "isDeprecated": false,
312
312
  "deprecationReason": null
313
+ },
314
+ {
315
+ "name": "verifiableResultsHash",
316
+ "description": null,
317
+ "args": [
318
+
319
+ ],
320
+ "type": {
321
+ "kind": "SCALAR",
322
+ "name": "String",
323
+ "ofType": null
324
+ },
325
+ "isDeprecated": false,
326
+ "deprecationReason": null
327
+ },
328
+ {
329
+ "name": "verifiableResultsUrl",
330
+ "description": null,
331
+ "args": [
332
+
333
+ ],
334
+ "type": {
335
+ "kind": "SCALAR",
336
+ "name": "String",
337
+ "ofType": null
338
+ },
339
+ "isDeprecated": false,
340
+ "deprecationReason": null
313
341
  }
314
342
  ],
315
343
  "inputFields": null,
@@ -442,13 +470,9 @@
442
470
 
443
471
  ],
444
472
  "type": {
445
- "kind": "NON_NULL",
446
- "name": null,
447
- "ofType": {
448
- "kind": "SCALAR",
449
- "name": "JSON",
450
- "ofType": null
451
- }
473
+ "kind": "SCALAR",
474
+ "name": "JSON",
475
+ "ofType": null
452
476
  },
453
477
  "isDeprecated": false,
454
478
  "deprecationReason": null
@@ -1232,28 +1256,28 @@
1232
1256
  "description": "Autogenerated return type of PublishResultsMutation",
1233
1257
  "fields": [
1234
1258
  {
1235
- "name": "election",
1259
+ "name": "error",
1236
1260
  "description": null,
1237
1261
  "args": [
1238
1262
 
1239
1263
  ],
1240
1264
  "type": {
1241
- "kind": "OBJECT",
1242
- "name": "Election",
1265
+ "kind": "SCALAR",
1266
+ "name": "String",
1243
1267
  "ofType": null
1244
1268
  },
1245
1269
  "isDeprecated": false,
1246
1270
  "deprecationReason": null
1247
1271
  },
1248
1272
  {
1249
- "name": "error",
1273
+ "name": "pendingMessage",
1250
1274
  "description": null,
1251
1275
  "args": [
1252
1276
 
1253
1277
  ],
1254
1278
  "type": {
1255
- "kind": "SCALAR",
1256
- "name": "String",
1279
+ "kind": "OBJECT",
1280
+ "name": "PendingMessage",
1257
1281
  "ofType": null
1258
1282
  },
1259
1283
  "isDeprecated": false,
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/bulletin_board/graphql/file_adapter"
4
+
3
5
  module Decidim
4
6
  module BulletinBoard
5
7
  module Graphql
@@ -12,6 +14,15 @@ module Decidim
12
14
  "Authorization" => settings.authority_api_key
13
15
  })
14
16
  end
17
+
18
+ def self.client_for_file(settings, file_path)
19
+ Graphlient::Client.new(file_path,
20
+ schema_path: File.join(__dir__, "bb_schema.json"),
21
+ http: FileAdapter,
22
+ headers: {
23
+ "Authorization" => settings.authority_api_key
24
+ })
25
+ end
15
26
  end
16
27
  end
17
28
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ module Decidim
6
+ module BulletinBoard
7
+ module Graphql
8
+ class FileAdapter
9
+ attr_reader :file_name
10
+
11
+ def initialize(file_name, _options = {}, &_block)
12
+ @file_name = file_name
13
+ end
14
+
15
+ def execute(document:, operation_name: nil, variables: {}, context: {})
16
+ body = {}
17
+ body["query"] = document.to_query_string
18
+ body["variables"] = variables if variables.any?
19
+ body["operationName"] = operation_name if operation_name
20
+
21
+ CSV.open(file_name, "a+", col_sep: ";") do |csv|
22
+ csv << [JSON.generate(body), context[:headers]["Authorization"]]
23
+ end
24
+
25
+ { "data" => { "vote" => {} } }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -60,6 +60,10 @@ module Decidim
60
60
  @message_id
61
61
  end
62
62
 
63
+ def unique_trustee_id(authority_slug, trustee_name)
64
+ "#{authority_slug}.#{trustee_name}"
65
+ end
66
+
63
67
  class << self
64
68
  def format(unique_election_id, type_subtype, author_type, author_id)
65
69
  "#{unique_election_id}.#{type_subtype}+#{INVERTED_AUTHOR_TYPE[author_type]}.#{author_id}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Decidim
4
4
  module BulletinBoard
5
- VERSION = "0.12.1"
5
+ VERSION = "0.15.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-bulletin_board
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Morcillo
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-02-22 00:00:00.000000000 Z
14
+ date: 2021-03-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -154,8 +154,6 @@ files:
154
154
  - ".rubocop.yml"
155
155
  - ".ruby-version"
156
156
  - ".travis.yml"
157
- - CHANGELOG.md
158
- - CODE_OF_CONDUCT.md
159
157
  - Gemfile
160
158
  - Gemfile.lock
161
159
  - README.md
@@ -163,7 +161,6 @@ files:
163
161
  - app/assets/config/manifest.js
164
162
  - app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js
165
163
  - bin/console
166
- - bin/release
167
164
  - bin/setup
168
165
  - decidim-bulletin_board.gemspec
169
166
  - lib/decidim/bulletin_board.rb
@@ -178,15 +175,17 @@ files:
178
175
  - lib/decidim/bulletin_board/client.rb
179
176
  - lib/decidim/bulletin_board/command.rb
180
177
  - lib/decidim/bulletin_board/engine.rb
178
+ - lib/decidim/bulletin_board/file_client.rb
181
179
  - lib/decidim/bulletin_board/graphql/bb_schema.json
182
180
  - lib/decidim/bulletin_board/graphql/factory.rb
181
+ - lib/decidim/bulletin_board/graphql/file_adapter.rb
183
182
  - lib/decidim/bulletin_board/jwk_utils.rb
184
183
  - lib/decidim/bulletin_board/message_identifier.rb
185
184
  - lib/decidim/bulletin_board/settings.rb
186
185
  - lib/decidim/bulletin_board/version.rb
187
186
  - lib/decidim/bulletin_board/voter/cast_vote.rb
188
187
  - lib/decidim/bulletin_board/voter/get_pending_message_status.rb
189
- homepage: https://github.com
188
+ homepage: https://github.com/decidim/decidim-bulletin-board
190
189
  licenses:
191
190
  - AGPL-3.0
192
191
  metadata: {}
data/CHANGELOG.md DELETED
@@ -1,228 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## Unreleased
9
-
10
- ## [0.12.1] - 2021-02-22
11
-
12
- ### Changed
13
-
14
- - The `VoteComponent` event names have been changed to more suitable ones.
15
-
16
- ## [0.12.0] - 2021-02-19
17
-
18
- ### Added
19
-
20
- - The `Voter` returns the ballot hash after encrpyting the plain vote and before auditing or casting it
21
-
22
- ### Changed
23
-
24
- - The `create_election` command now expects objects representing the parts public keys.
25
-
26
- ## [0.11.0] - 2021-02-18
27
-
28
- ### Changed
29
-
30
- - Changed the name of some settings\* to improve the readability of the code:
31
- - BB settings: `bulletin_board_server`\* and `bulletin_board_public_key`\*.
32
- - Authority settings: `authority_api_key`\*, `authority_name` and `authority_private_key`\*.
33
- - Elections settings: `scheme_name`, `number_of_trustees` and `quorum`.
34
- - `KeyCeremonyComponent` and `TallyComponent` now accepts a `trusteeWrapperAdapter` object.
35
- - The `processMessage` method from the `TrusteeWrapperAdapter` now accepts a `messageType` instead of a `messageIdentifier`.
36
-
37
- ### Removed
38
-
39
- - The `TrusteeWrapper` for the "dummy" voting scheme has been removed from the project.
40
-
41
- ### Added
42
-
43
- - The `TrusteeWrapperAdapter` abstract class can be used to implement any voting scheme wrapper adapter.
44
-
45
- ## [0.10.1] - 2021-02-15
46
-
47
- ### Fixed
48
-
49
- - The `TallyComponent` now uses the `key_ceremony` messages as well.
50
-
51
- ## [0.10.0] - 2021-02-12
52
-
53
- ## Added
54
-
55
- - A command to get decoded election results.
56
- - The (Bulletin Board) server public key is now included in the gem configuration.
57
- - The option to `audit` a vote.
58
-
59
- ## Changed
60
-
61
- - The `get_election_log_entries_by_type` command got renamed to `get_election_results`.
62
- - The `create_election` command now receives all the information needed in a simple hash and builds the message to add to the election log. It only needs seven main keys: `trustees`, `default_locale`, `title`, `start_date`, `end_date`, `questions` and `answers`.
63
- - The `scheme` setting was replaced by the `scheme_name` and `quorum` settings.
64
-
65
- ## [0.9.2] - 2021-02-02
66
-
67
- ## [0.9.1] - 2021-02-02
68
-
69
- ## Added
70
-
71
- - The `VoteComponent` has been added. It will be used as a glue code between the vote and the UI.
72
- - The ruby client now includes the `get_election_log_entries_by_types` method to get the election log entries filtered by type.
73
-
74
- ## [0.9.0] - 2021-02-01
75
-
76
- ## Changed
77
-
78
- - The `open_ballot_box` and `close_ballot_box` are now called `start_vote` and `end_vote` and return a pending message.
79
- - All the client operations yield the `message_id` before sending the request to the Bulletin Board.
80
-
81
- ## Added
82
-
83
- - `start_key_ceremony` method to the `Decidim::BulletinBoard::Client`.
84
- - The `IdentificationKeys` class has been added to the JS library.
85
- - The `TallyComponent` has been added. It will be used as a glue code between the tally and the UI.
86
-
87
- ## [0.8.2] - 2021-01-28
88
-
89
- ## Changed
90
-
91
- - `encrypt` in `VoterWrapperDummy` has a TimeOut of 500ms.
92
-
93
- ## [0.8.0] - 2021-01-27
94
-
95
- ## Changed
96
-
97
- - `getPendingMessage` can get queried by `messageId` and by `id`.
98
- - `get_status` renamed to `get_election_status` in the `Decidim::BulletinBoard::Client`.
99
-
100
- ## Added
101
-
102
- - `getPendingMessageStatus` method to the `Decidim::BulletinBoard::Client`.
103
- - `waitForPendingMessageToBeProcessed` method to the Voter class.
104
- - The `KeyCeremonyComponent` has been added. It will be used as a glue code between the key ceremony process and the UI.
105
-
106
- ## [0.7.0] - 2021-01-26
107
-
108
- ## Changed
109
-
110
- - The `Trustee` class now uses the `Election` class to interact with the log entries.
111
- - The `Trustee` class handles everything now when performing both the key ceremony and the tally process.
112
- - The `Trustee` class now includes a `setupKeyCeremony` generator function that must be called before starting the key ceremony process.
113
- - `checkRestoreNeeded` method has been renamed to `needsToBeRestored` for both the `Trustee` and the `TrusteeWrapper`.
114
-
115
- ## Added
116
-
117
- - `start_tally` method to the `Decidim::BulletinBoard::Client`.
118
- - `publish_results` method to the `Decidim::BulletinBoard::Client`.
119
- - `Election` class in the JS package to handle the election state. An instance of this class will be used by the key ceremony and the trustee to check anything related to log entries.
120
- - The `Trustee` class now has a `teardown` method that is called automatically to clean a few things. It can be called early to avoid memory leaks if needed.
121
- - The `EventManager` class now handles the `events` stream and exports some useful constants.
122
-
123
- ## Removed
124
-
125
- - The `KeyCeremony` class has been removed.
126
- - The `Trustee` backup method has been removed because it doesn't belong to the public API anymore.
127
-
128
- ## [0.6.1] - 2021-01-12
129
-
130
- ### Changed
131
-
132
- - Production file now is called `decidim-bulletin_board.js` and development file is called `decidim-bulletin_board.dev.js`.
133
-
134
- ### Removed
135
-
136
- - The GraphQL client doesn't use subscriptions anymore.
137
-
138
- ## [0.6.0] - 2021-01-12
139
-
140
- ### Changed
141
-
142
- - Updated the app schema definition with the partial log entries list retrieval
143
- - Gem is an engine, the js assets can be imported in Decidim.
144
-
145
- ## [0.5.3] - 2020-12-20
146
-
147
- ### Fixed
148
-
149
- - Fix the schema definition folder when used inside an app
150
-
151
- ## [0.5.2] - 2020-12-20
152
-
153
- ### Fixed
154
-
155
- - Include the schema definition within the gem to avoid extra trips to the server
156
-
157
- ## [0.5.1] - 2020-12-19
158
-
159
- ### Fixed
160
-
161
- - Include the missing `close_ballot_box` method from the 0.4.0 release.
162
- - Fixes for the client methods
163
-
164
- ## [0.5.0] - 2020-12-19
165
-
166
- ### Changed
167
-
168
- - Renamed `setup_election` to `create_election` and moved `election_id` from the `election_data` to a separate argument.
169
-
170
- ### Fixed
171
-
172
- - Include the missing `open_ballot_box` methods from the 0.4.0 release.
173
- - Added missing namespace on the seed task
174
-
175
- ## [0.4.0] - 2020-12-18
176
-
177
- ### Added
178
-
179
- - `content_hash` field for the `LogEntry` records with the hash of the `content` field, if included in the message.
180
- - `Command` base class for all the classes representing GraphQL queries or mutations sent to the Bulletin Board.
181
- - `open_ballot_box` and `close_ballot_box` methods to the `Decidim::BulletinBoard::Client`.
182
-
183
- ### Changed
184
-
185
- - New format for the messages: `iat`, `message_id` and Bulletin Board fields in the root message, and `content` for the Voting Scheme messages.
186
- - Improved consistency between methods included by `Decidim::BulletinBoard::Client`.
187
-
188
- ## [0.3.1] - 2020-12-10
189
-
190
- ### Fixed
191
-
192
- - Uses the correct private key in the `sign_data` method.
193
-
194
- ## [0.3.0] - 2020-12-10
195
-
196
- ### Added
197
-
198
- - `Decidim::BulletinBoard::Authority` namespace that includes commands and forms to get the status of an election.
199
-
200
- ### Changed
201
-
202
- - `Decidim::BulletinBoard::Client` now includes a `get_status` method to get the election status using the `Authority` namespace.
203
-
204
- ### Fixed
205
-
206
- - `Decidim::BulletinBoard::Voter::CastVote` command uses the `encrypted_vote` as a `String` and not as a `Hash`.
207
-
208
- ## [0.2.0] - 2020-12-08
209
-
210
- ### Added
211
-
212
- - `Decidim::BulletinBoard::Voter` namespace that includes commands and forms to perform the cast vote action.
213
-
214
- ### Changed
215
-
216
- - `Decidim::BulletinBoard::Client` now includes a `cast_vote` method to cast a vote using the `Voter` namespace.
217
-
218
- ## [0.1.0] - 2020-12-07
219
-
220
- ### Added
221
-
222
- - `Decidim::BulletinBoard::Client` class totally configurable using `ActiveSupport::Configurable`
223
- - The client now includes a `setup_election` method that creates the election in the bulletin board.
224
-
225
- [unreleased]: https://github.com/decidim/decidim-bulletin-board/compare/v0.3.0...HEAD
226
- [0.3.0]: https://github.com/decidim/decidim-bulletin-board/compare/v0.2.0...v0.3.0
227
- [0.2.0]: https://github.com/decidim/decidim-bulletin-board/compare/v0.1.0...v0.2.0
228
- [0.1.0]: https://github.com/decidim/decidim-bulletin-board/releases/tag/v0.1.0