ogam 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ded9c968a17644837dd792f5e1e5b7a0b01569772b216cebb10b9a100db888f
4
- data.tar.gz: 7932280e0b64ba87fbb5a3f7e5dee03d9e159b28dc621bb5e96cb11b6d8b8bc3
3
+ metadata.gz: b41adf475cb00cb57164e2bbb0e330d3b7d0401abd7725cc4ddc39325e2e8e9f
4
+ data.tar.gz: 8519c7e4f82dfcdd87e2efde8fa0651841984d136fe6f4853bf85e042e1bdf1c
5
5
  SHA512:
6
- metadata.gz: 504c052a371e7a6eebe7833cd773381a3d2a9d6b9d2a30623925475360eec3ad8614499fbe23bb4930c255359cc1aca06c91a9982102585ce8cdf9c1770dc1a5
7
- data.tar.gz: daa018bb77aa0c9caf4e3619938d2dbc962eb30f6166b184e567f44210e8b7bd65d18c6d840d5fb5a3d044e0f6bff9e727bdf71c34e1efe19afc24e5ee685be1
6
+ metadata.gz: 1d05195e69269c8700c50806953046a7676b9f380658d2168292795759c6b5be139b594362313fe2e378e192a6f4d2e8fd71efa6d43375fed08339b2ebdd1da6
7
+ data.tar.gz: 4ac972b6caf6c6b3f37f1ebd37f47fb8e76b12526394aa8c9d00bdd8ca6b58b4902b54be22780d7750a1f67de35e6d69bb8669363929edd8f168ff42d4fa1f71
@@ -5,8 +5,17 @@ inherit_gem:
5
5
  rubocop-ogat:
6
6
  - config/default.yml
7
7
 
8
+ inherit_mode:
9
+ merge:
10
+ - 'Include'
11
+
8
12
  AllCops:
9
13
  TargetRubyVersion: 2.6
14
+ Include:
15
+ - 'bin/ogam'
16
+ Exclude:
17
+ - 'bin/console'
18
+ - 'vendor/bundle/**/*'
10
19
 
11
20
  Rails:
12
21
  Enabled: false
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 10000 --no-offense-counts --no-auto-gen-timestamp`
3
- # using RuboCop version 0.80.1.
3
+ # using RuboCop version 0.82.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Configuration parameters: Max.
9
+ # Configuration parameters: IgnoredMethods, Max.
10
10
  Metrics/AbcSize:
11
11
  Exclude:
12
12
  - 'spec/**/*'
@@ -24,7 +24,7 @@ Metrics/ClassLength:
24
24
  - 'config/environments/*.rb'
25
25
  - 'lib/ogam/group_assigner.rb'
26
26
 
27
- # Configuration parameters: Max.
27
+ # Configuration parameters: IgnoredMethods, Max.
28
28
  Metrics/CyclomaticComplexity:
29
29
  Exclude:
30
30
  - 'spec/**/*'
@@ -42,7 +42,7 @@ Metrics/MethodLength:
42
42
  - 'config/environments/*.rb'
43
43
  - 'lib/ogam/group_assigner.rb'
44
44
 
45
- # Configuration parameters: Max.
45
+ # Configuration parameters: IgnoredMethods, Max.
46
46
  Metrics/PerceivedComplexity:
47
47
  Exclude:
48
48
  - 'spec/**/*'
data/bin/ogam CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'ogam'
6
- require 'thor'
7
- require 'shellwords'
4
+ require "bundler/setup"
5
+ require "ogam"
6
+ require "thor"
7
+ require "shellwords"
8
8
 
9
9
  # Signature subcommand cli
10
10
  class SignatureCLI < Thor
11
- desc('user EMAIL', 'Sets the signature for user with primary email EMAIL based on their name, job title, and org')
11
+ desc("user EMAIL", "Sets the signature for user with primary email EMAIL based on their name, job title, and org")
12
12
  def user(email)
13
13
  set_signatures(Ogam::User.active_by_email(email), pretend: parent_options[:pretend])
14
14
  end
15
15
 
16
- desc('domain DOMAIN', 'Sets the signature for all users @DOMAIN based on their name, job title, and org')
16
+ desc("domain DOMAIN", "Sets the signature for all users @DOMAIN based on their name, job title, and org")
17
17
  def domain(domain)
18
18
  set_signatures(Ogam::User.active_for_domain(domain), pretend: parent_options[:pretend])
19
19
  end
@@ -32,38 +32,38 @@ class CLI < Thor
32
32
  class_option :pretend, type: :boolean, default: false
33
33
 
34
34
  desc(
35
- 'assign_to_standard_groups DOMAIN_OR_EMAIL',
36
- 'Assigns users at DOMAIN (e.g. newbold.outwood.com) or EMAIL address to standard groups based on their job title'
35
+ "assign_to_standard_groups DOMAIN_OR_EMAIL",
36
+ "Assigns users at DOMAIN (e.g. newbold.outwood.com) or EMAIL address to standard groups based on their job title"
37
37
  )
38
38
  def assign_to_standard_groups(domain_or_email)
39
- method = domain_or_email.include?('@') ? :for_user : :for_domain
39
+ method = domain_or_email.include?("@") ? :for_user : :for_domain
40
40
  Ogam::GroupAssigner.public_send(method, domain_or_email, pretend: options[:pretend])
41
41
  end
42
42
 
43
43
  desc(
44
- 'populate_titles_and_orgs PATH_TO_CSV',
45
- 'Populates job titles and organisation names from a CSV with columns primary_email, job_title, organisation'
44
+ "populate_titles_and_orgs PATH_TO_CSV",
45
+ "Populates job titles and organisation names from a CSV with columns primary_email, job_title, organisation"
46
46
  )
47
47
  def populate_titles_and_orgs(csv_path)
48
48
  Ogam::Execute.csv_command(
49
49
  csv_path,
50
- 'gam update user ~primary_email organization name ~organisation title ~job_title primary',
50
+ "gam update user ~primary_email organization name ~organisation title ~job_title primary",
51
51
  pretend: options[:pretend]
52
52
  )
53
53
  end
54
54
 
55
- desc('create_shared_mailbox EMAIL NAME', 'Create a shared mailbox')
55
+ desc("create_shared_mailbox EMAIL NAME", "Create a shared mailbox")
56
56
  def create_shared_mailbox(email, name)
57
57
  Ogam::Execute.single(Ogam::Group.create_shared_mailbox_command(email, name), pretend: options[:pretend])
58
58
  end
59
59
 
60
- desc('create_exec_mailbox EMAIL NAME', 'Create an Exec mailbox')
60
+ desc("create_exec_mailbox EMAIL NAME", "Create an Exec mailbox")
61
61
  def create_exec_mailbox(email, name)
62
62
  Ogam::Execute.single(Ogam::Group.create_exec_mailbox_command(email, name), pretend: options[:pretend])
63
63
  end
64
64
 
65
65
  option :moderated, type: :boolean, default: false
66
- desc('create_group EMAIL NAME [--moderated]', 'Create a distribution list group, optionally moderated')
66
+ desc("create_group EMAIL NAME [--moderated]", "Create a distribution list group, optionally moderated")
67
67
  def create_group(email, name)
68
68
  Ogam::Execute.single(
69
69
  Ogam::Group.create_distribution_list_command(email, name, options[:moderated]), pretend: options[:pretend]
@@ -72,8 +72,8 @@ class CLI < Thor
72
72
 
73
73
  option :organisation, type: :string
74
74
  desc(
75
- 'set_job_title EMAIL TITLE [--organisation ORG_NAME]',
76
- 'Sets job title for a user, and updates their signature, groups, and organisation name. Optionally override org.'
75
+ "set_job_title EMAIL TITLE [--organisation ORG_NAME]",
76
+ "Sets job title for a user, and updates their signature, groups, and organisation name. Optionally override org."
77
77
  )
78
78
  def set_job_title(email, title)
79
79
  validate_job_title!(title)
@@ -86,27 +86,28 @@ class CLI < Thor
86
86
  end
87
87
 
88
88
  desc(
89
- 'add_send_as USER GROUP NAME TITLE ORG_NAME',
90
- 'Adds a sendas address to USER to be able to send as GROUP, and sets the NAME, and signature for sending'
89
+ "add_send_as USER GROUP NAME TITLE ORG_NAME",
90
+ "Adds a sendas address to USER to be able to send as GROUP, and sets the NAME, and signature for sending"
91
91
  )
92
92
  def add_send_as(user, group, name, title, org_name)
93
93
  signature_html = Ogam::Signature.signature_html(name, title, org_name)
94
94
  Ogam::Execute.single(Ogam::Group.add_send_as_command(user, group, name, signature_html), pretend: options[:pretend])
95
95
  end
96
96
 
97
- desc('set_signature user/domain EMAIL/DOMAIN', 'Set email signatures for users/domains based on user attributes')
98
- subcommand 'set_signature', SignatureCLI
97
+ desc("set_signature user/domain EMAIL/DOMAIN", "Set email signatures for users/domains based on user attributes")
98
+ subcommand "set_signature", SignatureCLI
99
99
 
100
- desc('delicense_suspended_ou', 'De-licenses GSEfE from all users under /Suspended')
100
+ desc("delicense_suspended_ou", "De-licenses GSEfE from all users under /Suspended")
101
101
  def delicense_suspended_ou
102
102
  Ogam::Execute.single('gam ou "/Suspended" delete license 1010310002', pretend: options[:pretend])
103
103
  end
104
104
 
105
- desc('suspend USER', 'Suspends a user, moves them to /Suspended, and delicenses GSEfE')
106
- def suspend(user)
105
+ desc("offboard USER", "Suspends a user, moves them to /Suspended, removes from groups, and delicenses GSEfE")
106
+ def offboard(user)
107
107
  Ogam::Execute.single(
108
108
  "gam update user #{user} suspended on org \"/Suspended\"", pretend: options[:pretend]
109
109
  )
110
+ Ogam::Execute.single("gam user #{user} delete groups", pretend: options[:pretend])
110
111
  puts "Waiting 5 seconds before delicensing..."
111
112
  sleep(5)
112
113
  Ogam::Execute.single("gam user #{user} delete license 1010310002", pretend: options[:pretend])
@@ -123,7 +124,7 @@ class CLI < Thor
123
124
  end
124
125
 
125
126
  def validate_organisation!(org, approved_organisations)
126
- org.split(' / ').each do |org_part|
127
+ org.split(" / ").each do |org_part|
127
128
  unless approved_organisations.value?(org_part)
128
129
  raise ArgumentError, "'#{org_part}' is not an approved organisation name."
129
130
  end
@@ -133,7 +134,7 @@ class CLI < Thor
133
134
  def infer_organisation_if_necessary(org, email, approved_organisations)
134
135
  return org if org.present?
135
136
 
136
- approved_organisations.fetch(email.split('@').last, '')
137
+ approved_organisations.fetch(email.split("@").last, "")
137
138
  end
138
139
 
139
140
  def set_title_and_org_and_make_changes(email, title, org, pretend: true)
@@ -32,6 +32,7 @@ module Ogam
32
32
  single("gam csv #{Shellwords.escape(csv_path)} #{command.strip}", pretend: pretend)
33
33
  end
34
34
 
35
+ # rubocop:disable Metrics/MethodLength
35
36
  def self.multiple(commands, pretend: true)
36
37
  return if commands.empty?
37
38
 
@@ -41,10 +42,12 @@ module Ogam
41
42
  end
42
43
  return if pretend
43
44
 
44
- Tempfile.create do |f|
45
- commands.each { |command| f.puts command.strip }
46
- single("gam batch #{f.path}", pretend: pretend)
47
- end
45
+ f = Tempfile.new
46
+ commands.each { |command| f.puts command.strip }
47
+ f.close
48
+ single("gam batch #{f.path}", pretend: pretend)
49
+ f.unlink
48
50
  end
51
+ # rubocop:enable Metrics/MethodLength
49
52
  end
50
53
  end
@@ -9,7 +9,7 @@ module Ogam
9
9
  end
10
10
 
11
11
  def self.add_group_member_command(user:, group:)
12
- "gam update group #{group} add member user #{user}"
12
+ "gam update group #{group} add member user #{Shellwords.escape(user)}"
13
13
  end
14
14
 
15
15
  def self.create_shared_mailbox_command(email_address, name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ogam
4
- VERSION = "1.3.1"
4
+ VERSION = "1.3.2"
5
5
  end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 2.1"
34
34
  spec.add_development_dependency "rake", "~> 13.0"
35
35
  spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_development_dependency "rubocop-ogat", "~> 2.0.1"
36
+ spec.add_development_dependency "rubocop-ogat", "~> 2.6.0"
37
37
  spec.add_development_dependency "simplecov", "~> 0.18.4"
38
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ogam
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elliot Bowes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-01 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.0.1
103
+ version: 2.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.0.1
110
+ version: 2.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: simplecov
113
113
  requirement: !ruby/object:Gem::Requirement