From 96ea415b51db6629c20811edd73bdc578a284f07 Mon Sep 17 00:00:00 2001 From: mose Date: Tue, 23 Feb 2016 13:55:06 +0800 Subject: [PATCH] cleaning up and more testing api routes --- app/apiv1.rb | 1 - spec/app/apiv1_spec.rb | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app/apiv1.rb b/app/apiv1.rb index 53424a0..e578021 100644 --- a/app/apiv1.rb +++ b/app/apiv1.rb @@ -116,7 +116,6 @@ def check_authorization hiera = Hieracles::Hiera.new(hieracles_config) nodeinfo = Hieracles::Node.new(node, hieracles_config) facts = Hieraviz::Facts.new(settings.configdata['tmpdir'], base, node, get_username) - puts facts.instance_variable_get(:@filename) res = { 'hiera' => hiera.hierarchy, 'vars' => hiera.params, diff --git a/spec/app/apiv1_spec.rb b/spec/app/apiv1_spec.rb index 030d96e..1bbb2c6 100644 --- a/spec/app/apiv1_spec.rb +++ b/spec/app/apiv1_spec.rb @@ -213,7 +213,6 @@ it { expect(File).to exist(factsfile) } end - describe "DELETE /v1/node/node1.example.com/facts" do let(:tmpdir) { "spec/files/tmp" } let(:base) { "" } @@ -230,7 +229,6 @@ it { expect(File).not_to exist(factsfile) } end - describe "GET /v1/farms" do let(:expected) { { "farm1" => 0 } } before do @@ -248,6 +246,43 @@ it { expect(last_response).to be_ok } it { expect(JSON.parse last_response.body).to eq expected } end + + describe "GET /v1/node/node1.example.com/hierarchy" do + let(:expected) { + { + "hiera" => [ + "nodes/%{fqdn}", + "farm/%{farm}", + "common/common" + ], + "vars" => [ + "fqdn", + "farm" + ], + "info" => { + "fqdn" => "node1.example.com", + "country" => "fr", + "datacenter" => "equinix", + "farm" => "dev", + "classes" => [ + "farm1" + ] + }, + "files" => [ + "params/nodes/node1.example.com.yaml" + ], + "facts" => {}, + "defaults" => nil + } + } + before do + get '/node/node1.example.com/hierarchy' + end + it { expect(last_response).to be_ok } + it { expect(JSON.parse last_response.body).to eq expected } + end + + end end