|
145 | 145 | end |
146 | 146 | end |
147 | 147 |
|
| 148 | + describe 'Profile by App Group Name API' do |
| 149 | + let(:headers) do |
| 150 | + { 'ACCEPT' => 'application/json', 'HTTP_ACCEPT' => 'application/json' } |
| 151 | + end |
| 152 | + |
| 153 | + it 'should return profile information of registered app when supplied cluster name' do |
| 154 | + app_group = create(:app_group) |
| 155 | + helm_infrastructure = create( |
| 156 | + :helm_infrastructure, |
| 157 | + app_group: app_group, |
| 158 | + status: HelmInfrastructure.statuses[:active] |
| 159 | + ) |
| 160 | + |
| 161 | + get api_v2_profile_by_app_group_name_path, |
| 162 | + params: { access_token: @access_token, app_group_name: app_group.name }, |
| 163 | + headers: headers |
| 164 | + json_response = JSON.parse(response.body) |
| 165 | + |
| 166 | + %w[cluster_name status provisioning_status]. |
| 167 | + each do |key| |
| 168 | + expect(json_response.key?(key)).to eq(true) |
| 169 | + expect(json_response[key]).to eq(helm_infrastructure.send(key.to_sym)) |
| 170 | + end |
| 171 | + |
| 172 | + expect(json_response['app_group_name']).to eq(helm_infrastructure.app_group_name) |
| 173 | + expect(json_response['app_group_secret']).to eq(helm_infrastructure.app_group_secret) |
| 174 | + expect(json_response['capacity']).to eq(helm_infrastructure.helm_cluster_template.name) |
| 175 | + expect(json_response.key?('updated_at')).to eq(true) |
| 176 | + expect(json_response['kibana_address']).to eq(helm_infrastructure.kibana_address) |
| 177 | + end |
| 178 | + |
| 179 | + it 'should return K8s Kibana if activated' do |
| 180 | + app_group = create(:app_group) |
| 181 | + helm_infrastructure = create(:helm_infrastructure, |
| 182 | + app_group: app_group, |
| 183 | + status: HelmInfrastructure.statuses[:active], |
| 184 | + cluster_name: 'haza', |
| 185 | + ) |
| 186 | + |
| 187 | + get api_v2_profile_by_app_group_name_path, |
| 188 | + params: { access_token: @access_token, app_group_name: app_group.name }, |
| 189 | + headers: headers |
| 190 | + json_response = JSON.parse(response.body) |
| 191 | + |
| 192 | + expect(json_response['kibana_address']).to eq("#{helm_infrastructure.cluster_name}-kb-http.barito-worker.svc:5601") |
| 193 | + expect(json_response['kibana_address']).to eq(helm_infrastructure.kibana_address) |
| 194 | + end |
| 195 | + |
| 196 | + context 'when App Group unavailable' do |
| 197 | + it 'should return 404' do |
| 198 | + error_msg = 'App Group not found' |
| 199 | + app_group = create(:app_group) |
| 200 | + helm_infrastructure = create(:helm_infrastructure, app_group: app_group) |
| 201 | + |
| 202 | + get api_v2_profile_by_app_group_name_path, |
| 203 | + params: { access_token: @access_token, app_group_name: app_group.name }, |
| 204 | + headers: headers |
| 205 | + json_response = JSON.parse(response.body) |
| 206 | + |
| 207 | + expect(json_response['success']).to eq false |
| 208 | + expect(json_response['code']).to eq 404 |
| 209 | + expect(json_response['errors']).to eq [error_msg] |
| 210 | + end |
| 211 | + end |
| 212 | + end |
| 213 | + |
148 | 214 | describe 'Profile for Curator' do |
149 | 215 | let(:headers) do |
150 | 216 | { 'ACCEPT' => 'application/json', 'HTTP_ACCEPT' => 'application/json' } |
|
213 | 279 | } |
214 | 280 | ].to_json |
215 | 281 | end |
216 | | - |
217 | | - |
218 | 282 | end |
219 | 283 |
|
220 | 284 | describe 'Profile for Prometheus Exporters' do |
|
0 commit comments