icfs 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/icfs/validate.rb CHANGED
@@ -10,7 +10,6 @@
10
10
  # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
11
 
12
12
  require 'set'
13
- require 'json'
14
13
  require 'tempfile'
15
14
 
16
15
  module ICFS
@@ -18,71 +17,9 @@ module ICFS
18
17
  ##########################################################################
19
18
  # Object validation
20
19
  #
21
- # @todo Move .parse and .generate to items or ICFS
22
- # @todo Remove all use of Error module
23
- #
24
20
  module Validate
25
21
 
26
22
 
27
- ###############################################
28
- # Parse JSON string and validate
29
- #
30
- # @param json [String] the JSON to parse
31
- # @param name [String] description of the item
32
- # @param val [Hash] the check to use
33
- # @return [Object] the item
34
- #
35
- # @raise [Error::NotFound] if json is nil
36
- # @raise [Error::Value] if parsing or validation fails
37
- #
38
- def self.parse(json, name, val)
39
- if json.nil?
40
- raise(Error::NotFound, '%s not found'.freeze % name)
41
- end
42
- begin
43
- itm = JSON.parse(json)
44
- rescue
45
- raise(Error::Value, 'JSON parsing failed'.freeze)
46
- end
47
- Validate.validate(itm, name, val)
48
- return itm
49
- end # def self.parse()
50
-
51
-
52
- ###############################################
53
- # Validate and generate JSON
54
- #
55
- # @param itm [Object] item to validate
56
- # @param name [String] description of the item
57
- # @param val [Hash] the check to use
58
- # @return [String] JSON encoded item
59
- #
60
- # @raise [Error::Value] if validation fails
61
- #
62
- def self.generate(itm, name, val)
63
- Validate.validate(itm, name, val)
64
- return JSON.pretty_generate(itm)
65
- end # def self.generate()
66
-
67
-
68
- ###############################################
69
- # Validate an object
70
- #
71
- # @param obj [Object] object to validate
72
- # @param name [String] description of the object
73
- # @param val [Hash] the check to use
74
- #
75
- # @raise [Error::Value] if validation fails
76
- #
77
- def self.validate(obj, name, val)
78
- err = Validate.check(obj, val)
79
- if err
80
- raise(Error::Value, '%s has bad values: %s'.freeze %
81
- [name, err.inspect])
82
- end
83
- end
84
-
85
-
86
23
  ###############################################
87
24
  # check an object
88
25
  #
@@ -55,12 +55,20 @@ class AuthSsl
55
55
  return [
56
56
  400,
57
57
  {'Content-Type' => 'text/plain'.freeze},
58
- ['User not found for %s' % env['SSL_CLIENT_S_DN']]
58
+ ['%s: No User' % env['SSL_CLIENT_S_DN']]
59
59
  ]
60
60
  end
61
61
 
62
62
  # pass to app
63
- @api.user = user
63
+ begin
64
+ @api.user = user
65
+ rescue Error::NotFound, Error::Value => err
66
+ return [
67
+ 400,
68
+ {'Content-Type' => 'text/plain'.freeze},
69
+ ['%s: %s' % [err.message, env['SSL_CLIENT_S_DN']]]
70
+ ]
71
+ end
64
72
  env['icfs'] = @api
65
73
  return @app.call(env)
66
74
  end # def call()
@@ -562,7 +562,7 @@ class Client
562
562
 
563
563
  # process entry
564
564
  ent = _post_entry(env, para)
565
- Validate.validate(tid, 'Template ID'.freeze, Items::FieldCaseid)
565
+ Items.validate(tid, 'Template ID'.freeze, Items::FieldCaseid)
566
566
  ent['caseid'] = cid
567
567
 
568
568
  # create
@@ -4268,7 +4268,7 @@ class Client
4268
4268
  raise(Error::NotFound, 'No case specified in the URL'.freeze)
4269
4269
  end
4270
4270
  cid = Rack::Utils.unescape(cmps[1])
4271
- Validate.validate(cid, 'case'.freeze, Items::FieldCaseid)
4271
+ Items.validate(cid, 'case'.freeze, Items::FieldCaseid)
4272
4272
  env['icfs.cid'] = cid
4273
4273
  return cid
4274
4274
  end # def _util_case()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham A. Field
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2-
14
14
 
@@ -24,12 +24,22 @@ extensions: []
24
24
  extra_rdoc_files: []
25
25
  files:
26
26
  - LICENSE.txt
27
+ - bin/icfs_demo_check.rb
27
28
  - bin/icfs_demo_create.rb
28
29
  - bin/icfs_demo_fcgi.rb
29
30
  - bin/icfs_demo_ssl_gen.rb
30
31
  - bin/icfs_demo_web.rb
31
32
  - bin/icfs_dev_todo.rb
32
33
  - data/demo_config.yml
34
+ - data/docker/build-web.sh
35
+ - data/docker/compose-demo.yml
36
+ - data/docker/compose-init.yml
37
+ - data/docker/icfs-app.rb
38
+ - data/docker/icfs-cfg.yml
39
+ - data/docker/icfs-init.rb
40
+ - data/docker/icfs-ruby/Dockerfile
41
+ - data/docker/icfs-ruby/build.sh
42
+ - data/docker/nginx.conf
33
43
  - data/icfs.css
34
44
  - data/icfs.js
35
45
  - lib/icfs.rb
@@ -47,6 +57,8 @@ files:
47
57
  - lib/icfs/users.rb
48
58
  - lib/icfs/users_elastic.rb
49
59
  - lib/icfs/users_fs.rb
60
+ - lib/icfs/utils/backup.rb
61
+ - lib/icfs/utils/check.rb
50
62
  - lib/icfs/validate.rb
51
63
  - lib/icfs/web/auth_ssl.rb
52
64
  - lib/icfs/web/client.rb