avmtrf1-tools 0.37.0 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avmtrf1/git/gitlab.rb +1 -1
  3. data/lib/avmtrf1/git/push_large/lfs_commit.rb +1 -1
  4. data/lib/avmtrf1/git/push_large/source_commit.rb +1 -1
  5. data/lib/avmtrf1/gitlab/repository.rb +1 -1
  6. data/lib/avmtrf1/{core_ext.rb → tools/core_ext.rb} +0 -0
  7. data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
  8. data/lib/avmtrf1/tools/msgraph.rb +11 -0
  9. data/lib/avmtrf1/tools/runner/app_src.rb +1 -1
  10. data/lib/avmtrf1/tools/runner/check_point/login.rb +1 -1
  11. data/lib/avmtrf1/tools/runner/check_point.rb +1 -1
  12. data/lib/avmtrf1/tools/runner/esosti/changed.rb +1 -1
  13. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +1 -1
  14. data/lib/avmtrf1/tools/runner/esosti/request.rb +1 -1
  15. data/lib/avmtrf1/tools/runner/esosti.rb +1 -1
  16. data/lib/avmtrf1/tools/runner/forponto/espelho.rb +1 -1
  17. data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +1 -1
  18. data/lib/avmtrf1/tools/runner/forponto/resumos.rb +1 -1
  19. data/lib/avmtrf1/tools/runner/forponto/saldo.rb +1 -1
  20. data/lib/avmtrf1/tools/runner/forponto.rb +1 -1
  21. data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +1 -1
  22. data/lib/avmtrf1/tools/runner/git/gitlab.rb +1 -1
  23. data/lib/avmtrf1/tools/runner/git/issues_check.rb +1 -1
  24. data/lib/avmtrf1/tools/runner/git/push_large.rb +1 -1
  25. data/lib/avmtrf1/tools/runner/git.rb +1 -1
  26. data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
  27. data/lib/avmtrf1/tools/runner/msgraph.rb +29 -0
  28. data/lib/avmtrf1/tools/runner/oracle/query.rb +1 -1
  29. data/lib/avmtrf1/tools/runner/oracle/source_get.rb +1 -1
  30. data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +1 -1
  31. data/lib/avmtrf1/tools/runner/oracle.rb +1 -1
  32. data/lib/avmtrf1/tools/runner/red.rb +1 -1
  33. data/lib/avmtrf1/tools/runner/trf1_dspace_base0.rb +1 -1
  34. data/lib/avmtrf1/tools/version.rb +1 -1
  35. data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
  36. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31c309491959a0594c3df8dc41fc1289c23bf01a1b49098ab71ab088ee1902ae
4
- data.tar.gz: 6e6e2234030d966e8bfc89e7d4d55b9012f59152dcc62694cde7a7ebdd8d8b5f
3
+ metadata.gz: 48fb6d183fcf0b449c91abd20944f74ebd440d719ead3b6a02668d9b4def2554
4
+ data.tar.gz: b30b7c8baccbbd700be03c2823c7dbdfc7adc828dfb036409f3ab70d9b083800
5
5
  SHA512:
6
- metadata.gz: 74b0a854547a9cbab8d4f46114d8e5cce72a3a149c5d9028ee92c8e8ad2779aef249e1cdce545d0cab0d9a2990a14a5b17a99f71ce2a8cc39bc762f955bc8dfe
7
- data.tar.gz: 2c924ccd64479d9b4e6bd6e8a47b2e5a7d30beefac7bd1763731cf6b48598325f088614c0b510312e8b3b96b92493e3b3ae8d947dbe8fd9c7292c0db008d4393
6
+ metadata.gz: 2d57fbca329752db6d22248da2205cef1bc52518af47e90ba8e44d6629a8bbd14bc0617b18bc12a16e543a5e6ca0ff144dfacf851c1bc5749041431df96e128a
7
+ data.tar.gz: 5995b88d6360f46ac73c95e6631cb3f70d4540cb99e44f7ca7ec3809043369a56f8d788f2b2c0b1af37ee0aa9c4c2828b431a574b844e48ee67fa9d53e6047db
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/git/commit'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Git
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Gitlab
File without changes
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_rest/api'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/temp'
6
+ require 'avmtrf1/template'
7
+
8
+ module Avmtrf1
9
+ module Tools
10
+ module Msgraph
11
+ class TokenRetrieve
12
+ enable_simple_cache
13
+ common_constructor :client_id
14
+
15
+ private
16
+
17
+ def python_retrieve_command(file)
18
+ ::EacRubyUtils::Envs.local.command(python_retrieve_program_path, client_id, file)
19
+ end
20
+
21
+ # @return [Hash]
22
+ def result_uncached
23
+ ::EacRubyUtils::Yaml.load(result_string)
24
+ end
25
+
26
+ # @return [String]
27
+ def result_string
28
+ ::EacRubyUtils::Fs::Temp.on_file do |file|
29
+ raise ::RuntimeError, result.pretty_inspect unless python_retrieve_command(file.to_path)
30
+ .system
31
+
32
+ file.read
33
+ end
34
+ end
35
+
36
+ def python_retrieve_program_path
37
+ template.child('python_retriever.py').path
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ module Msgraph
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/app_src'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avmtrf1/check_point/session'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'yaml'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/default_esosti'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avmtrf1/forponto/user/day_registers'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/forponto/user/balance'
5
5
 
6
6
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_config/node'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
  require 'avmtrf1/forponto/user'
6
6
 
7
7
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
  require 'avmtrf1/gitlab/commit'
6
6
  require 'avmtrf1/gitlab/repository'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/git/cached_repository'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/git/push_large'
5
5
 
6
6
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+ require 'avmtrf1/tools/msgraph/token_retrieve'
5
+
6
+ module Avmtrf1
7
+ module Tools
8
+ class Runner
9
+ class Msgraph
10
+ class Token
11
+ runner_with :help, :output
12
+
13
+ def run
14
+ infov 'Client ID', token_retrieve.client_id
15
+ run_output
16
+ end
17
+
18
+ private
19
+
20
+ def output_content
21
+ ::EacRubyUtils::Yaml.dump(token_retrieve.result)
22
+ end
23
+
24
+ def token_retrieve_uncached
25
+ ::Avmtrf1::Tools::Msgraph::TokenRetrieve.new(runner_context.call(:client_id))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Msgraph
9
+ require_sub __FILE__
10
+ runner_with :help, :subcommands do
11
+ arg_opt '-i', '--client-id', 'ID de aplicação cliente alternativo.'
12
+ subcommands
13
+ end
14
+
15
+ def client_id
16
+ client_id_by_argument || client_id_by_config
17
+ end
18
+
19
+ def client_id_by_argument
20
+ parsed.client_id.presence
21
+ end
22
+
23
+ def client_id_by_config
24
+ ::EacConfig::Node.context.current.entry('msgraph.client_id').value
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/oracle/connection/base.rb'
5
5
  require 'avmtrf1/oracle/connection/string_builder.rb'
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/ini'
5
5
  require 'avmtrf1/red/profile'
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/trf1_dspace_base0/instance'
5
5
 
6
6
  module Avmtrf1
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avmtrf1
4
4
  module Tools
5
- VERSION = '0.37.0'
5
+ VERSION = '0.38.0'
6
6
  end
7
7
  end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Requirements
4
+ # pyperclip>=1.6.0
5
+ # requests>=2.18.4
6
+ # adal>=1.0.0
7
+ # pyyaml
8
+
9
+ from adal import AuthenticationContext
10
+ import argparse
11
+ import pyperclip
12
+ import sys
13
+ import webbrowser
14
+ import yaml
15
+
16
+
17
+ class Config:
18
+ AUTHORITY_URL = 'https://login.microsoftonline.com/common'
19
+ RESOURCE = 'https://graph.microsoft.com'
20
+ API_VERSION = 'beta'
21
+
22
+
23
+ class TokenInfo:
24
+ def __init__(self, args):
25
+ self.__device = None
26
+ self.__token = None
27
+ self.__context = None
28
+ self.__args = args
29
+
30
+ def context(self):
31
+ if not self.__context:
32
+ self.__context = AuthenticationContext(Config.AUTHORITY_URL,
33
+ api_version=None)
34
+ return self.__context
35
+
36
+ def device(self):
37
+ if not self.__device:
38
+ self.__device = self.context().acquire_user_code(
39
+ Config.RESOURCE, self.__args.client_id)
40
+ return self.__device
41
+
42
+ def token(self, auto=True):
43
+ if not self.__token:
44
+ device_code = self.device()
45
+ if auto:
46
+ pyperclip.copy(
47
+ device_code['user_code']) # copy user code to clipboard
48
+ webbrowser.open(
49
+ device_code['verification_url']) # open browser
50
+ self.info(
51
+ f'The code {device_code["user_code"]} has been copied to your clipboard, '
52
+ f'and your web browser is opening {device_code["verification_url"]}. '
53
+ 'Paste the code to sign in.\n')
54
+ else:
55
+ self.info(device_code['message'])
56
+
57
+ self.__token = self.context().acquire_token_with_device_code(
58
+ Config.RESOURCE, device_code, self.__args.client_id)
59
+ return self.__token
60
+
61
+ def info(self, message):
62
+ sys.stderr.write(message + "\n")
63
+
64
+ def result(self):
65
+ if self.token():
66
+ return {'device': self.device(), 'token': self.token()}
67
+ else:
68
+ return None
69
+
70
+ def run(self):
71
+ if self.result():
72
+ with open(self.__args.output_path, 'w') as outfile:
73
+ yaml.dump(self.result(), outfile, default_flow_style=False)
74
+ self.info('Result writed in "%s"' % (self.__args.output_path))
75
+ else:
76
+ sys.exit("Result empty!")
77
+
78
+
79
+ if __name__ == '__main__':
80
+ parser = argparse.ArgumentParser(
81
+ description='Recupera token de acesso ao MSGraph')
82
+ parser.add_argument('client_id')
83
+ parser.add_argument('output_path')
84
+ args = parser.parse_args()
85
+ TokenInfo(args).run()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avmtrf1-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.37.0
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2022-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-selenium
@@ -148,7 +148,6 @@ files:
148
148
  - lib/avmtrf1/check_point.rb
149
149
  - lib/avmtrf1/check_point/session.rb
150
150
  - lib/avmtrf1/check_point/session/login.rb
151
- - lib/avmtrf1/core_ext.rb
152
151
  - lib/avmtrf1/default_esosti.rb
153
152
  - lib/avmtrf1/default_jira.rb
154
153
  - lib/avmtrf1/default_redmine.rb
@@ -284,6 +283,9 @@ files:
284
283
  - lib/avmtrf1/template.rb
285
284
  - lib/avmtrf1/tools.rb
286
285
  - lib/avmtrf1/tools/application.rb
286
+ - lib/avmtrf1/tools/core_ext.rb
287
+ - lib/avmtrf1/tools/msgraph.rb
288
+ - lib/avmtrf1/tools/msgraph/token_retrieve.rb
287
289
  - lib/avmtrf1/tools/runner.rb
288
290
  - lib/avmtrf1/tools/runner/app_src.rb
289
291
  - lib/avmtrf1/tools/runner/check_point.rb
@@ -303,6 +305,8 @@ files:
303
305
  - lib/avmtrf1/tools/runner/git/issues_check.rb
304
306
  - lib/avmtrf1/tools/runner/git/push_large.rb
305
307
  - lib/avmtrf1/tools/runner/inventario_sistemas.rb
308
+ - lib/avmtrf1/tools/runner/msgraph.rb
309
+ - lib/avmtrf1/tools/runner/msgraph/token.rb
306
310
  - lib/avmtrf1/tools/runner/node_js.rb
307
311
  - lib/avmtrf1/tools/runner/node_js/docker.rb
308
312
  - lib/avmtrf1/tools/runner/openvpn.rb
@@ -338,6 +342,7 @@ files:
338
342
  - template/avmtrf1/php/docker_image/aux/setup_apache_site.sh
339
343
  - template/avmtrf1/php/docker_image/aux/start.sh
340
344
  - template/avmtrf1/php/docker_image/aux/templates/apache_site.conf
345
+ - template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py
341
346
  - template/avmtrf1/trf1_dspace_base0/deploy/build.properties.template
342
347
  homepage: http://redmine.trf1.gov.br/projects/avm-trf1
343
348
  licenses: []