diff --git a/lib/miq_expression/tag.rb b/lib/miq_expression/tag.rb index fad09f8dc5c..3040a29b219 100644 --- a/lib/miq_expression/tag.rb +++ b/lib/miq_expression/tag.rb @@ -1,6 +1,6 @@ class MiqExpression::Tag < MiqExpression::Target REGEX = / -(?([[:alnum:]]*(::)?){4}) +(?(?:[[:upper:]][[:alnum:]]*(?:::[[:upper:]][[:alnum:]]*)*)?) \.?(?([a-z_]+\.)*) (?\bmanaged|user_tag\b) -(?[a-z]+[_[:alnum:]]+) diff --git a/spec/lib/miq_expression/tag_spec.rb b/spec/lib/miq_expression/tag_spec.rb index 2bae6b588f9..93492ad094a 100644 --- a/spec/lib/miq_expression/tag_spec.rb +++ b/spec/lib/miq_expression/tag_spec.rb @@ -36,21 +36,21 @@ end it "with model.associations.managed-in_tag" do - tag = "service.user.managed-service_level" + tag = "Service.user.managed-service_level" expect(described_class.parse(tag)).to have_attributes(:model => Service, :associations => ['user'], :namespace => "/managed/service_level") end it "with model.associations.user_tag-in_tag" do - tag = "service.user.user_tag-service_level" + tag = "Service.user.user_tag-service_level" expect(described_class.parse(tag)).to have_attributes(:model => Service, :associations => ['user'], :namespace => "/user/service_level") end it "with invalid case model.associations.managed-in_tag" do - tag = "service.user.mXaXnXaXged-service_level" + tag = "Service.user.mXaXnXaXged-service_level" expect(described_class.parse(tag)).to be_nil end @@ -72,9 +72,18 @@ end it "returns nil with invalid case parent-model::model::somethingmanaged-se" do - tag = "ManageIQ::Providers::CloudManagermanaged-se'" + tag = "ManageIQ::Providers::CloudManagermanaged-se" expect(described_class.parse(tag)).to be_nil end + + it "can parse models in deeply nested namespaces" do + tag = "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem.managed-cc" + + expected = { + :model => ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem + } + expect(described_class.parse(tag)).to have_attributes(expected) + end end describe "#to_s" do