public GenerateToken ( string sessionId, Role role = Role.PUBLISHER, double expireTime, string data = null ) : string | ||
sessionId | string | |
role | Role | |
expireTime | double | |
data | string | |
리턴 | string |
public void GenerateTokenWithExpireTimeTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); double expireTime = OpenTokUtils.GetCurrentUnixTimeStamp() + 10; String sessionId = "1_MX4xMjM0NTZ-flNhdCBNYXIgMTUgMTQ6NDI6MjMgUERUIDIwMTR-MC40OTAxMzAyNX4"; string token = opentok.GenerateToken(sessionId, expireTime: expireTime); Assert.NotNull(token); var data = CheckToken(token, apiKey); Assert.Equal(data["partner_id"], apiKey.ToString()); Assert.NotNull(data["sig"]); Assert.NotNull(data["create_time"]); Assert.NotNull(data["nonce"]); Assert.Equal(data["role"], Role.PUBLISHER.ToString()); Assert.Equal(data["expire_time"], ((long) expireTime).ToString()); }
public void GenerateTokenWithRoleTest() { OpenTok opentok = new OpenTok(apiKey, apiSecret); String sessionId = "1_MX4xMjM0NTZ-flNhdCBNYXIgMTUgMTQ6NDI6MjMgUERUIDIwMTR-MC40OTAxMzAyNX4"; string token = opentok.GenerateToken(sessionId, role:Role.SUBSCRIBER); Assert.NotNull(token); var data = CheckToken(token, apiKey); Assert.Equal(data["partner_id"], apiKey.ToString()); Assert.NotNull(data["sig"]); Assert.NotNull(data["create_time"]); Assert.NotNull(data["nonce"]); Assert.Equal(data["role"], Role.SUBSCRIBER.ToString()); }
public void GenerateInvalidTokensTest() { string token; OpenTok opentok = new OpenTok(apiKey, apiSecret); var exceptions = new List<Exception>(); try { // Generate token with empty sessionId token = opentok.GenerateToken(null); } catch(OpenTokArgumentException e) { exceptions.Add(e); } try { // Generate token with empty sessionId token = opentok.GenerateToken(""); } catch (OpenTokArgumentException e) { exceptions.Add(e); } try { // Generate token with empty sessionId token = opentok.GenerateToken("NOT A VALID SESSION ID"); } catch (OpenTokArgumentException e) { exceptions.Add(e); } Assert.Equal(exceptions.Count, 3); foreach(Exception exception in exceptions) { Assert.True(exception is OpenTokArgumentException); } }