38658f0c6f3fda585db0d42af548e803d76899d8
[moon.git] /
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.aaa.shiro.authorization;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13
14 import com.google.common.collect.Sets;
15 import java.util.Collection;
16 import org.junit.Test;
17
18 /**
19  * A few basic test cases for the DefualtRBACRules singleton container.
20  *
21  * @author Ryan Goulding (ryandgoulding@gmail.com)
22  *
23  */
24 public class DefaultRBACRulesTest {
25
26     @Test
27     public void testGetInstance() {
28         assertNotNull(DefaultRBACRules.getInstance());
29         assertEquals(DefaultRBACRules.getInstance(), DefaultRBACRules.getInstance());
30     }
31
32     @Test
33     public void testGetRBACRules() {
34         Collection<RBACRule> rbacRules = DefaultRBACRules.getInstance().getRBACRules();
35         assertNotNull(rbacRules);
36
37         // check that a copy was returned
38         int originalSize = rbacRules.size();
39         rbacRules.add(RBACRule.createAuthorizationRule("fakeurl/*", Sets.newHashSet("admin")));
40         assertEquals(originalSize, DefaultRBACRules.getInstance().getRBACRules().size());
41     }
42
43 }