summaryrefslogtreecommitdiff
path: root/features/api/search/show_search.feature
blob: 292d043b0dafeeeb4ae4f16b294f3d68d27411b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@api @data @api_search @api_search_show
Feature: Search data via the REST API
  In order to know about objects in the system
  As a Developer
  I want to search the objects 

  Scenario: Search for objects when none have been created
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users' 
     Then the inflated responses key 'rows' should be '0' items long
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '0'

  Scenario: Search for objects when one has been created
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '1' 

  Scenario: Search for objects when two have been created
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And a 'data_bag_item' named 'axl_rose' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
      And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '1' key 'id' should be 'axl_rose'
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '2' 

  Scenario: Search for objects with a manual ascending sort order 
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And a 'data_bag_item' named 'axl_rose' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users?sort=id+asc' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
      And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '1' key 'id' should be 'francis'
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '2' 

  Scenario: Search for objects with a manual descending sort order 
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And a 'data_bag_item' named 'axl_rose' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users?sort=id+desc' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
      And the inflated responses key 'rows' item '1' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '1' key 'id' should be 'axl_rose'
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '2' 

  Scenario: Search for objects and page through the results
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And a 'data_bag_item' named 'axl_rose' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users?rows=1&sort=id+asc' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
      And the inflated responses key 'rows' should be '1' items long
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '2'
     When I 'GET' the path '/search/users?rows=1&start=1&sort=id+asc' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'francis'
      And the inflated responses key 'rows' should be '1' items long
      And the inflated responses key 'start' should be the integer '1'
      And the inflated responses key 'total' should be the integer '2'

  Scenario: Search for a subset of objects 
    Given a 'registration' named 'bobo' exists
      And a 'data_bag' named 'users' exists
      And a 'data_bag_item' named 'francis' exists
      And a 'data_bag_item' named 'axl_rose' exists
      And I wait for '10' seconds
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/users?q=id:axl_rose' 
     Then the inflated responses key 'rows' item '0' should be a kind of 'Chef::DataBagItem'
      And the inflated responses key 'rows' item '0' key 'id' should be 'axl_rose'
      And the inflated responses key 'start' should be the integer '0'
      And the inflated responses key 'total' should be the integer '1' 

  Scenario: Search for a type of object that does not exist 
    Given a 'registration' named 'bobo' exists
     When I authenticate as 'bobo'
      And I 'GET' the path '/search/funkensteins'
     Then I should get a '404 "Not Found"' exception

  Scenario: Search for objects when you are not authenticated 
     When I 'GET' the path '/search/users' 
     Then I should get a '401 "Unauthorized"' exception