blob: 9b7c971220f66726ef0c1899a7630e4000726496 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*
* Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.aaa.authn.mdsal.store;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.aaa.api.model.Domain;
import org.opendaylight.aaa.api.model.Grant;
import org.opendaylight.aaa.api.model.Role;
import org.opendaylight.aaa.api.model.User;
public class MDSALConvertTest {
@Test
public void testConvertDomain() {
Domain d = new Domain();
d.setDescription("hello");
d.setDomainid("hello");
d.setEnabled(true);
d.setName("Hello");
org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Domain mdsalDomain = IDMObject2MDSAL.toMDSALDomain(d);
Assert.assertNotNull(mdsalDomain);
Domain d2 = IDMObject2MDSAL.toIDMDomain(mdsalDomain);
Assert.assertNotNull(d2);
Assert.assertEquals(d, d2);
}
@Test
public void testConvertRole() {
Role r = new Role();
r.setDescription("hello");
r.setRoleid("Hello@hello");
r.setName("Hello");
r.setDomainid("hello");
org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Role mdsalRole = IDMObject2MDSAL.toMDSALRole(r);
Assert.assertNotNull(mdsalRole);
Role r2 = IDMObject2MDSAL.toIDMRole(mdsalRole);
Assert.assertNotNull(r2);
Assert.assertEquals(r, r2);
}
@Test
public void testConvertUser() {
User u = new User();
u.setDescription("hello");
u.setDomainid("hello");
u.setUserid("hello@hello");
u.setName("Hello");
u.setEmail("email");
u.setEnabled(true);
u.setPassword("pass");
u.setSalt("salt");
org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.User mdsalUser = IDMObject2MDSAL.toMDSALUser(u);
Assert.assertNotNull(mdsalUser);
User u2 = IDMObject2MDSAL.toIDMUser(mdsalUser);
Assert.assertNotNull(u2);
Assert.assertEquals(u, u2);
}
@Test
public void testConvertGrant() {
Grant g = new Grant();
g.setDomainid("hello");
g.setUserid("hello@hello");
g.setRoleid("hello@hello");
g.setGrantid("hello@hello@Hello");
org.opendaylight.yang.gen.v1.urn.aaa.yang.authn.claims.rev141029.authentication.Grant mdsalGrant = IDMObject2MDSAL.toMDSALGrant(g);
Assert.assertNotNull(mdsalGrant);
Grant g2 = IDMObject2MDSAL.toIDMGrant(mdsalGrant);
Assert.assertNotNull(g2);
Assert.assertEquals(g, g2);
}
}
|