|
16 | 16 |
|
17 | 17 | package com.splunk; |
18 | 18 |
|
| 19 | +import java.net.HttpCookie; |
19 | 20 | import java.util.HashMap; |
20 | 21 | import java.util.Map; |
21 | 22 |
|
22 | | -import org.junit.Assert; |
23 | | -import org.junit.Assume; |
24 | | -import org.junit.Before; |
25 | | -import org.junit.Test; |
| 23 | +import org.junit.*; |
26 | 24 |
|
27 | 25 | public class CookieTest extends SDKTestCase { |
28 | 26 |
|
@@ -124,6 +122,32 @@ public void testLoginWithMultipleCookies() { |
124 | 122 | s.getSettings().refresh(); |
125 | 123 | } |
126 | 124 |
|
| 125 | + @Test |
| 126 | + public void testLoginWithOtherCookies() { |
| 127 | + String otherCookies = "load=balancer;"; |
| 128 | + service.logout(); |
| 129 | + service.cookieStore.removeAll(); |
| 130 | + service.cookieStore.add(otherCookies); |
| 131 | + service.login(); |
| 132 | + service.getApplications(); |
| 133 | + service.cookieStore.removeAll(); |
| 134 | + } |
| 135 | + |
| 136 | + @Test |
| 137 | + public void testUsingAuthTokenAndOtherCookie(){ |
| 138 | + String validToken = service.getToken(); |
| 139 | + Assert.assertTrue(validToken.startsWith("Splunk ")); |
| 140 | + String otherCookies = "load=balancer;"; |
| 141 | + Map<String, Object> args = new HashMap<>(); |
| 142 | + args.put("cookie", otherCookies); |
| 143 | + args.put("host",service.getHost()); |
| 144 | + args.put("port", service.getPort()); |
| 145 | + Service s = new Service(args); |
| 146 | + s.setToken(validToken); |
| 147 | + s.getApplications(); |
| 148 | + Assert.assertEquals(otherCookies.trim(),s.cookieStore.getCookies().trim()); |
| 149 | + } |
| 150 | + |
127 | 151 | @Test |
128 | 152 | public void testLoginWithMultipleInvalidCookies() { |
129 | 153 | String validCookie = service.stringifyCookies(); |
|
0 commit comments