|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package org.apache.cloudstack.api.response; |
| 19 | + |
| 20 | + |
| 21 | +import org.junit.Assert; |
| 22 | +import org.junit.Test; |
| 23 | + |
| 24 | +public class LoginCmdResponseTest { |
| 25 | + |
| 26 | + @Test |
| 27 | + public void testAllGettersAndSetters() { |
| 28 | + LoginCmdResponse response = new LoginCmdResponse(); |
| 29 | + |
| 30 | + response.setUsername("user1"); |
| 31 | + response.setUserId("100"); |
| 32 | + response.setDomainId("200"); |
| 33 | + response.setTimeout(3600); |
| 34 | + response.setAccount("account1"); |
| 35 | + response.setFirstName("John"); |
| 36 | + response.setLastName("Doe"); |
| 37 | + response.setType("admin"); |
| 38 | + response.setTimeZone("UTC"); |
| 39 | + response.setTimeZoneOffset("+00:00"); |
| 40 | + response.setRegistered("true"); |
| 41 | + response.setSessionKey("session-key"); |
| 42 | + response.set2FAenabled("true"); |
| 43 | + response.set2FAverfied("false"); |
| 44 | + response.setProviderFor2FA("totp"); |
| 45 | + response.setIssuerFor2FA("cloudstack"); |
| 46 | + response.setManagementServerId("ms-1"); |
| 47 | + |
| 48 | + Assert.assertEquals("user1", response.getUsername()); |
| 49 | + Assert.assertEquals("100", response.getUserId()); |
| 50 | + Assert.assertEquals("200", response.getDomainId()); |
| 51 | + Assert.assertEquals(Integer.valueOf(3600), response.getTimeout()); |
| 52 | + Assert.assertEquals("account1", response.getAccount()); |
| 53 | + Assert.assertEquals("John", response.getFirstName()); |
| 54 | + Assert.assertEquals("Doe", response.getLastName()); |
| 55 | + Assert.assertEquals("admin", response.getType()); |
| 56 | + Assert.assertEquals("UTC", response.getTimeZone()); |
| 57 | + Assert.assertEquals("+00:00", response.getTimeZoneOffset()); |
| 58 | + Assert.assertEquals("true", response.getRegistered()); |
| 59 | + Assert.assertEquals("session-key", response.getSessionKey()); |
| 60 | + Assert.assertEquals("true", response.is2FAenabled()); |
| 61 | + Assert.assertEquals("false", response.is2FAverfied()); |
| 62 | + Assert.assertEquals("totp", response.getProviderFor2FA()); |
| 63 | + Assert.assertEquals("cloudstack", response.getIssuerFor2FA()); |
| 64 | + Assert.assertEquals("ms-1", response.getManagementServerId()); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + public void testPasswordChangeRequired_True() { |
| 69 | + LoginCmdResponse response = new LoginCmdResponse(); |
| 70 | + response.setPasswordChangeRequired(true); |
| 71 | + Assert.assertTrue(response.getPasswordChangeRequired()); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void testPasswordChangeRequired_False() { |
| 76 | + LoginCmdResponse response = new LoginCmdResponse(); |
| 77 | + response.setPasswordChangeRequired(false); |
| 78 | + Assert.assertFalse(response.getPasswordChangeRequired()); |
| 79 | + } |
| 80 | + |
| 81 | + @Test |
| 82 | + public void testPasswordChangeRequired_Null() { |
| 83 | + LoginCmdResponse response = new LoginCmdResponse(); |
| 84 | + response.setPasswordChangeRequired(null); |
| 85 | + Assert.assertNull("Boolean.parseBoolean(null) should return null", response.getPasswordChangeRequired()); |
| 86 | + } |
| 87 | +} |
0 commit comments