test/maestrano/maestrano_test.rb in maestrano-0.4.0 vs test/maestrano/maestrano_test.rb in maestrano-0.5.0

- old
+ new

@@ -21,14 +21,55 @@ config.sso_app_consume_path = @config[:sso_app_consume_path] config.user_creation_mode = @config[:user_creation_mode] end end - should "return the specified parameters" do - @config.keys.each do |key| - assert Maestrano.param(key) == @config[key] + context "param" do + should "return the specified parameters" do + @config.keys.each do |key| + assert Maestrano.param(key) == @config[key] + end end end + + context "authenticate" do + should "return true if app_id and api_key match" do + assert Maestrano.authenticate(Maestrano.param(:app_id),Maestrano.param(:api_key)) + end + + should "return false otherwise" do + assert !Maestrano.authenticate(Maestrano.param(:app_id) + 'a',Maestrano.param(:api_key)) + assert !Maestrano.authenticate(Maestrano.param(:app_id),Maestrano.param(:api_key) + 'a') + end + end + + context "mask_user_uid" do + should "return the composite uid if creation_mode is virtual" do + Maestrano.configure { |c| c.user_creation_mode = 'virtual' } + assert_equal 'usr-1.cld-1', Maestrano.mask_user('usr-1','cld-1') + end + + should "not double up the composite uid" do + Maestrano.configure { |c| c.user_creation_mode = 'virtual' } + assert_equal 'usr-1.cld-1', Maestrano.mask_user('usr-1.cld-1','cld-1') + end + + should "return the real uid if creation_mode is real" do + Maestrano.configure { |c| c.user_creation_mode = 'real' } + assert_equal 'usr-1', Maestrano.mask_user('usr-1','cld-1') + end + end + + context "unmask_user_uid" do + should "return the right uid if composite" do + assert_equal 'usr-1', Maestrano.unmask_user('usr-1.cld-1') + end + + should "return the right uid if non composite" do + assert_equal 'usr-1', Maestrano.unmask_user('usr-1') + end + end + context "configuration" do should "return the right test parameters" do Maestrano.configure { |config| config.environment = 'test' } \ No newline at end of file