Skip to content

Commit

Permalink
Adds ENV vars for configuring the BB server (#310)
Browse files Browse the repository at this point in the history
* add env vars for bb settings

* documentation

* fix rubocop

* Update bulletin_board/server/spec/commands/create_election_spec.rb

Co-authored-by: Andrés Pereira de Lucena <[email protected]>

* update rubocop

* update schema

* update schema

* add log level env

* rubocop

---------

Co-authored-by: Andrés Pereira de Lucena <[email protected]>
  • Loading branch information
microstudi and andreslucena authored Dec 14, 2023
1 parent 6e0a171 commit be58cb5
Show file tree
Hide file tree
Showing 34 changed files with 170 additions and 99 deletions.
2 changes: 1 addition & 1 deletion bulletin_board/js-client/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ export type QueryElectionArgs = {


export type QueryLogEntryArgs = {
electionUniqueId: Scalars['String'];
contentHash: Scalars['String'];
electionUniqueId: Scalars['String'];
};


Expand Down
13 changes: 10 additions & 3 deletions bulletin_board/ruby-client/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ gemspec
# Graphql version 2.1 breaks graphql-client compatibility See https://github.com/github/graphql-client/pull/310
gem "graphql", "~> 2.0.0"

gem "rubocop", "~> 1.28.0"
gem "rubocop-faker", "~> 1.1.0"
gem "rubocop-rspec", "~> 2.10"
gem "rubocop", "~> 1.57.0"
gem "rubocop-faker", "~> 1.1"
gem "rubocop-rspec", "~> 2.20"

group :development, :test do
gem "rake", "~> 13.0"
gem "rspec", "~> 3.7"
gem "webmock", "~> 3.6"
gem "wisper-rspec", "~> 1.1.0"
end
45 changes: 28 additions & 17 deletions bulletin_board/ruby-client/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ GEM
hashdiff (1.0.1)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.7.1)
jwt (2.5.0)
language_server-protocol (3.17.0.3)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand Down Expand Up @@ -160,9 +162,10 @@ GEM
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.1)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
public_suffix (5.0.0)
racc (1.7.1)
rack (2.2.8)
Expand Down Expand Up @@ -198,7 +201,7 @@ GEM
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
regexp_parser (2.8.3)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
Expand All @@ -213,29 +216,37 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.28.2)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.17.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
thor (1.2.2)
timeout (0.4.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.2.0)
unicode-display_width (2.5.0)
webmock (3.18.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand All @@ -257,9 +268,9 @@ DEPENDENCIES
graphql (~> 2.0.0)
rake (~> 13.0)
rspec (~> 3.7)
rubocop (~> 1.28.0)
rubocop-faker (~> 1.1.0)
rubocop-rspec (~> 2.10)
rubocop (~> 1.57.0)
rubocop-faker (~> 1.1)
rubocop-rspec (~> 2.20)
webmock (~> 3.6)
wisper-rspec (~> 1.1.0)

Expand Down
6 changes: 1 addition & 5 deletions bulletin_board/ruby-client/decidim-bulletin_board.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`
.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
.concat(["app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js"])
.push("app/assets/javascripts/decidim/bulletin_board/decidim-bulletin_board.js")
end
s.bindir = "exe"
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
Expand All @@ -31,9 +31,5 @@ Gem::Specification.new do |s|
s.add_dependency "jwt", "~> 2.5.0"
s.add_dependency "wisper", "~> 2.0.0"

s.add_development_dependency "rake", "~> 13.0"
s.add_development_dependency "rspec", "~> 3.7"
s.add_development_dependency "webmock", "~> 3.6"
s.add_development_dependency "wisper-rspec", "~> 1.1.0"
s.metadata["rubygems_mfa_required"] = "true"
end
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@
"description": "Returns the log entry with the given content hash for the given election",
"args": [
{
"name": "electionUniqueId",
"name": "contentHash",
"description": null,
"type": {
"kind": "NON_NULL",
Expand All @@ -1459,7 +1459,7 @@
"defaultValue": null
},
{
"name": "contentHash",
"name": "electionUniqueId",
"description": null,
"type": {
"kind": "NON_NULL",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def self.thumbprint(json)
end

def self.private_key?(json)
(json.keys & JWK_PRIVATE_FIELDS).any?
json.keys.intersect?(JWK_PRIVATE_FIELDS)
end

def self.import_private_key(json)
Expand Down
2 changes: 1 addition & 1 deletion bulletin_board/ruby-client/spec/support/command_stub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def stub_command(clazz, called_method, event_to_publish, *published_event_args)
end

# rubocop:disable Lint/EmptyBlock
define_method(:configure) { |*_args|; }
define_method(:configure) { |*_args| }
# rubocop:enable Lint/EmptyBlock
end)
end
10 changes: 10 additions & 0 deletions bulletin_board/server/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ inherit_from:
- https://raw.githubusercontent.com/decidim/decidim/develop/decidim-dev/config/rubocop/rspec.yml
- https://raw.githubusercontent.com/decidim/decidim/develop/decidim-dev/config/rubocop/rails.yml

require:
- rubocop-factory_bot
# TODO: Uncomment the following line when all the app/graphql/types have a description in their fields
# - rubocop-graphql

AllCops:
Include:
- "**/*.rb"
Expand All @@ -20,3 +25,8 @@ Style/OpenStructUse:

Rails/HasManyOrHasOneDependent:
Enabled: false

FactoryBot/FactoryAssociationWithStrategy:
Enabled: false


8 changes: 4 additions & 4 deletions bulletin_board/server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ group :development, :test do
gem "net-smtp", "~> 0.3.1"
gem "pry-rails"
gem "rspec-rails", "~> 4.1"
gem "rubocop", "~> 1.28.0"
gem "rubocop-faker", "~> 1.1.0"
gem "rubocop", "~> 1.57.0"
gem "rubocop-faker", "~> 1.1"
gem "rubocop-graphql", "~> 0.14.4"
gem "rubocop-rails", "~> 2.14"
gem "rubocop-rspec", "~> 2.10"
gem "rubocop-rails", "~> 2.22"
gem "rubocop-rspec", "~> 2.20"
end

group :development do
Expand Down
52 changes: 32 additions & 20 deletions bulletin_board/server/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.7.1)
jsonl (0.1.5)
jwt (2.5.0)
language_server-protocol (3.17.0.3)
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -225,9 +227,10 @@ GEM
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
parallel (1.22.1)
parser (3.1.2.1)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.4.3)
pry (0.14.1)
coderay (~> 1.1)
Expand Down Expand Up @@ -286,7 +289,7 @@ GEM
wisper (>= 1.6.1)
redcarpet (3.5.1)
redis (4.8.1)
regexp_parser (2.5.0)
regexp_parser (2.8.3)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
Expand All @@ -312,29 +315,38 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.28.2)
rubocop (1.57.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.17.0, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-graphql (0.14.4)
rubocop (>= 0.87, < 2)
rubocop-rails (2.15.1)
rubocop-rails (2.22.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
ruby-progressbar (1.11.0)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rspec (2.25.0)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
Expand Down Expand Up @@ -385,7 +397,7 @@ GEM
turbolinks-source (5.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.2.0)
unicode-display_width (2.5.0)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
Expand Down Expand Up @@ -445,11 +457,11 @@ DEPENDENCIES
redis (~> 4.0)
rspec-graphql_matchers
rspec-rails (~> 4.1)
rubocop (~> 1.28.0)
rubocop-faker (~> 1.1.0)
rubocop (~> 1.57.0)
rubocop-faker (~> 1.1)
rubocop-graphql (~> 0.14.4)
rubocop-rails (~> 2.14)
rubocop-rspec (~> 2.10)
rubocop-rails (~> 2.22)
rubocop-rspec (~> 2.20)
sass-rails (>= 6)
sidekiq (~> 6.0)
simplecov
Expand Down
2 changes: 1 addition & 1 deletion bulletin_board/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Bulletin Board is a service composed by an Encryption Engine and an Append-Only Log. External queries to the Encryption Engine are allowed through an API.

- Ruby version: 2.6
- Ruby version: 3.1
- Rails version: 6
- Python version: 3.8.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def pertinent_pending_messages
end

def clear_existing_file
File.delete(STATS_OUTPUT_FILE_PATH) if File.exist?(STATS_OUTPUT_FILE_PATH)
FileUtils.rm_f(STATS_OUTPUT_FILE_PATH)
end

def write_stats_to_file(stats)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class EndVoteMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
authority = find_authority(message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ProcessKeyCeremonyStepMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
trustee = find_trustee(message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ProcessTallyStepMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
trustee = find_trustee(message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class PublishResultsMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
authority = find_authority(message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ReportMissingTrusteeMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
authority = find_authority(message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class StartKeyCeremonyMutation < BaseMutation
argument :message_id, String, required: true
argument :signed_data, String, required: true

field :pending_message, Types::PendingMessageType, null: true
field :error, String, null: true
field :pending_message, Types::PendingMessageType, null: true

def resolve(message_id:, signed_data:)
authority = find_authority(message_id)
Expand Down
Loading

0 comments on commit be58cb5

Please sign in to comment.