opentok 0.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -2
  3. data/.travis.yml +6 -0
  4. data/.yardopts +1 -0
  5. data/CONTRIBUTING.md +47 -0
  6. data/DEVELOPING.md +91 -0
  7. data/LICENSE +19 -5
  8. data/README.md +170 -53
  9. data/Rakefile +10 -5
  10. data/doc/OpenTok.html +411 -0
  11. data/doc/OpenTok/Archive.html +1320 -0
  12. data/doc/OpenTok/ArchiveList.html +216 -0
  13. data/doc/OpenTok/Archives.html +1028 -0
  14. data/doc/OpenTok/Client.html +695 -0
  15. data/doc/OpenTok/OpenTok.html +1046 -0
  16. data/doc/OpenTok/OpenTokArchiveError.html +142 -0
  17. data/doc/OpenTok/OpenTokAuthenticationError.html +143 -0
  18. data/doc/OpenTok/OpenTokError.html +138 -0
  19. data/doc/OpenTok/Session.html +665 -0
  20. data/doc/OpenTok/TokenGenerator.html +204 -0
  21. data/doc/OpenTok/TokenGenerator/ClassMethods.html +187 -0
  22. data/doc/README.md +15 -0
  23. data/doc/_index.html +182 -0
  24. data/doc/class_list.html +54 -0
  25. data/doc/css/common.css +1 -0
  26. data/doc/css/full_list.css +57 -0
  27. data/doc/css/style.css +339 -0
  28. data/doc/file.README.html +87 -0
  29. data/doc/file_list.html +56 -0
  30. data/doc/frames.html +26 -0
  31. data/doc/index.html +87 -0
  32. data/doc/js/app.js +219 -0
  33. data/doc/js/full_list.js +178 -0
  34. data/doc/js/jquery.js +4 -0
  35. data/doc/method_list.html +227 -0
  36. data/doc/top-level-namespace.html +112 -0
  37. data/lib/opentok.rb +3 -14
  38. data/lib/opentok/archive.rb +92 -0
  39. data/lib/opentok/archive_list.rb +17 -0
  40. data/lib/opentok/archives.rb +120 -0
  41. data/lib/opentok/client.rb +125 -0
  42. data/lib/opentok/constants.rb +5 -0
  43. data/lib/opentok/exceptions.rb +10 -0
  44. data/lib/opentok/opentok.rb +174 -0
  45. data/lib/opentok/session.rb +76 -0
  46. data/lib/opentok/token_generator.rb +101 -0
  47. data/lib/opentok/version.rb +4 -0
  48. data/opentok.gemspec +29 -22
  49. data/sample/Archiving/Gemfile +4 -0
  50. data/sample/Archiving/README.md +212 -0
  51. data/sample/Archiving/archiving_sample.rb +80 -0
  52. data/sample/Archiving/public/css/sample.css +22 -0
  53. data/sample/Archiving/public/img/archiving-off.png +0 -0
  54. data/sample/Archiving/public/img/archiving-on-idle.png +0 -0
  55. data/sample/Archiving/public/img/archiving-on-message.png +0 -0
  56. data/sample/Archiving/public/js/host.js +37 -0
  57. data/sample/Archiving/public/js/participant.js +13 -0
  58. data/sample/Archiving/views/history.erb +65 -0
  59. data/sample/Archiving/views/host.erb +69 -0
  60. data/sample/Archiving/views/index.erb +48 -0
  61. data/sample/Archiving/views/layout.erb +29 -0
  62. data/sample/Archiving/views/participant.erb +55 -0
  63. data/sample/HelloWorld/Gemfile +4 -0
  64. data/sample/HelloWorld/README.md +123 -0
  65. data/sample/HelloWorld/hello_world.rb +27 -0
  66. data/sample/HelloWorld/public/js/helloworld.js +32 -0
  67. data/sample/HelloWorld/views/index.erb +21 -0
  68. data/spec/cassettes/OpenTok_Archives/should_create_archives.yml +48 -0
  69. data/spec/cassettes/OpenTok_Archives/should_create_named_archives.yml +49 -0
  70. data/spec/cassettes/OpenTok_Archives/should_delete_an_archive_by_id.yml +32 -0
  71. data/spec/cassettes/OpenTok_Archives/should_find_archives_by_id.yml +46 -0
  72. data/spec/cassettes/OpenTok_Archives/should_stop_archives.yml +48 -0
  73. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_all_archives.yml +104 -0
  74. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_archives_with_an_offset.yml +71 -0
  75. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_count_number_of_archives.yml +60 -0
  76. data/spec/cassettes/OpenTok_Archives/when_many_archives_are_created/should_return_part_of_the_archives_when_using_offset_and_count.yml +82 -0
  77. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_default_sessions.yml +39 -0
  78. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions.yml +39 -0
  79. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_relayed_media_sessions_with_a_location_hint.yml +39 -0
  80. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions.yml +39 -0
  81. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_for_invalid_media_modes.yml +39 -0
  82. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml +39 -0
  83. data/spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml +39 -0
  84. data/spec/matchers/token.rb +48 -0
  85. data/spec/opentok/archives_spec.rb +91 -0
  86. data/spec/opentok/opentok_spec.rb +144 -0
  87. data/spec/opentok/session_spec.rb +71 -0
  88. data/spec/shared/opentok_generates_tokens.rb +62 -0
  89. data/spec/shared/session_generates_tokens.rb +63 -0
  90. data/spec/spec_helper.rb +6 -7
  91. metadata +197 -59
  92. data/.rspec +0 -3
  93. data/CHANGES +0 -33
  94. data/doc/reference.md +0 -122
  95. data/lib/open_tok/archive.rb +0 -53
  96. data/lib/open_tok/archive_timeline_event.rb +0 -22
  97. data/lib/open_tok/archive_video_resource.rb +0 -28
  98. data/lib/open_tok/exception.rb +0 -50
  99. data/lib/open_tok/open_tok_sdk.rb +0 -198
  100. data/lib/open_tok/request.rb +0 -63
  101. data/lib/open_tok/role_constants.rb +0 -18
  102. data/lib/open_tok/session.rb +0 -25
  103. data/lib/open_tok/session_property_constants.rb +0 -30
  104. data/lib/open_tok/utils.rb +0 -10
  105. data/lib/open_tok/version.rb +0 -5
  106. data/sample/sample.rb +0 -26
  107. data/spec/cassettes/archives.yml +0 -83
  108. data/spec/cassettes/deleteArchive.yml +0 -91
  109. data/spec/cassettes/invalidSession.yml +0 -41
  110. data/spec/cassettes/session.yml +0 -46
  111. data/spec/cassettes/stitchArchive.yml +0 -42
  112. data/spec/opentok_exception_spec.rb +0 -38
  113. data/spec/opentok_spec.rb +0 -135
@@ -1,30 +0,0 @@
1
-
2
- module OpenTok
3
-
4
- ##
5
- # Preferences that could be defined while creating a session
6
- module SessionPropertyConstants
7
-
8
- # @deprecated (feature deleted in OpenTok v0.91.48)
9
- # @param [Boolean]
10
- ECHOSUPPRESSION_ENABLED = 'echoSuppression.enabled'
11
-
12
- # @deprecated (feature deleted in OpenTok v0.91.48)
13
- # @param [Integer]
14
- MULTIPLEXER_NUMOUTPUTSTREAMS = 'multiplexer.numOutputStreams'
15
-
16
- # @deprecated (feature deleted in OpenTok v0.91.48)
17
- # @param [Integer]
18
- MULTIPLEXER_SWITCHTYPE = 'multiplexer.switchType'
19
-
20
- # @deprecated (feature deleted in OpenTok v0.91.48)
21
- # @param [Integer]
22
- MULTIPLEXER_SWITCHTIMEOUT = 'multiplexer.switchTimeout'
23
-
24
- # Whether the session's streams will be transmitted directly between peers
25
- # @param [disabled, enabled]
26
- P2P_PREFERENCE = 'p2p.preference'
27
-
28
- end
29
-
30
- end
@@ -1,10 +0,0 @@
1
- require 'addressable/uri'
2
-
3
- module OpenTok
4
- module Utils
5
- def self.urlencode_hash(hash)
6
- uri = Addressable::URI.new :query_values => hash
7
- uri.query
8
- end
9
- end
10
- end
@@ -1,5 +0,0 @@
1
- module OpenTok
2
-
3
- VERSION = '0.1.3'
4
-
5
- end
@@ -1,26 +0,0 @@
1
- require 'opentok'
2
-
3
- API_KEY = '' # See https://dashboard.tokbox.com/
4
- API_SECRET = '' # See https://dashboard.tokbox.com/
5
-
6
- OTSDK = OpenTok::OpenTokSDK.new API_KEY, API_SECRET
7
-
8
- # Create an OpenTok server-enabled session
9
- sessionId = OTSDK.createSession().to_s
10
- print sessionId + "\n"
11
-
12
- # Create a peer-to-peer session
13
- sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"} # or disabled
14
- sessionId = OTSDK.createSession( nil, sessionProperties ).to_s
15
- print sessionId + "\n"
16
-
17
- # Generate a publisher token
18
- token = OTSDK.generateToken :session_id => sessionId
19
- print token + "\n"
20
-
21
- # Generate a token with moderator role and connection data
22
- role = OpenTok::RoleConstants::MODERATOR
23
- connection_data = "username=Bob,level=4, score=8888888888"
24
- token = OTSDK.generateToken :session_id => sessionId, :role => role, :connection_data => connection_data
25
- print token + "\n"
26
-
@@ -1,83 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: https://api.opentok.com/archive/getmanifest/200567af-0726-4e93-883b-fe0426d6310a
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- Accept:
11
- - ! '*/*'
12
- User-Agent:
13
- - Ruby
14
- X-Tb-Token-Auth:
15
- - T1==cGFydG5lcl9pZD00NTk3ODImc2lnPWVjNjA1YTZhNzI5MDk5MzU5NTI1YWM2ZTczNDY1ZTQ3MzEwMWFkY2Q6cm9sZT1tb2RlcmF0b3Imc2Vzc2lvbl9pZD0xX01YNDBOVGszT0RKLU1USTNMakF1TUM0eGZsUjFaU0JUWlhBZ01EUWdNVFE2TlRNNk1ESWdVRVJVSURJd01USi1NQzQxTWpFeE9ERXpmZyZjcmVhdGVfdGltZT0xMzQ2ODAxMjQ1Jm5vbmNlPTAuMjUwMTIwMTEyNzkzODkwMjQ=
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Server:
22
- - nginx
23
- Date:
24
- - Tue, 04 Sep 2012 23:27:13 GMT
25
- Content-Type:
26
- - text/xml; charset=utf-8
27
- Connection:
28
- - keep-alive
29
- Pragma:
30
- - no-cache
31
- Cache-Control:
32
- - no-cache
33
- Content-Length:
34
- - '510'
35
- body:
36
- encoding: US-ASCII
37
- string: ! "<manifest version=\"0.1\" archiveid=\"200567af-0726-4e93-883b-fe0426d6310a\"
38
- title=\"1346797109799\">\n <resources>\n <video id=\"bbf108c9-7237-49ae-9057-2ccdb71cf675\"
39
- length=\"18734\" name=\"\"/>\n <video id=\"3f0d3ec6-4a41-4cc5-9e38-f9e6375ba5fd\"
40
- length=\"18743\" name=\"\"/>\n </resources>\n <timeline>\n <event
41
- type=\"PLAY\" id=\"3f0d3ec6-4a41-4cc5-9e38-f9e6375ba5fd\" offset=\"1255\"
42
- data=\"\" />\n <event type=\"PLAY\" id=\"bbf108c9-7237-49ae-9057-2ccdb71cf675\"
43
- offset=\"1263\" data=\"\" />\n </timeline>\n</manifest>\n\n\n"
44
- http_version:
45
- recorded_at: Tue, 04 Sep 2012 23:27:25 GMT
46
- - request:
47
- method: get
48
- uri: https://api.opentok.com/archive/url/200567af-0726-4e93-883b-fe0426d6310a/bbf108c9-7237-49ae-9057-2ccdb71cf675
49
- body:
50
- encoding: US-ASCII
51
- string: ''
52
- headers:
53
- Accept:
54
- - ! '*/*'
55
- User-Agent:
56
- - Ruby
57
- X-Tb-Token-Auth:
58
- - T1==cGFydG5lcl9pZD00NTk3ODImc2lnPTU2MDY5Y2VmMTAzY2M4YTUzY2RlNTZlZTAzNzdjODIyNTk0MTU5MzM6cm9sZT1tb2RlcmF0b3Imc2Vzc2lvbl9pZD0xX01YNDBOVGszT0RKLU1USTNMakF1TUM0eGZsUjFaU0JUWlhBZ01EUWdNVFE2TlRNNk1ESWdVRVJVSURJd01USi1NQzQxTWpFeE9ERXpmZyZjcmVhdGVfdGltZT0xMzQ2ODAxMjQ1Jm5vbmNlPTAuNDY2MDM2NDg4Nzc5NDgy
59
- response:
60
- status:
61
- code: 200
62
- message: OK
63
- headers:
64
- Server:
65
- - nginx
66
- Date:
67
- - Tue, 04 Sep 2012 23:27:13 GMT
68
- Content-Type:
69
- - text/html; charset=utf-8
70
- Connection:
71
- - keep-alive
72
- Pragma:
73
- - no-cache
74
- Cache-Control:
75
- - no-cache
76
- Content-Length:
77
- - '229'
78
- body:
79
- encoding: US-ASCII
80
- string: https://s3.amazonaws.com/tokbox.com.production/459782/200567af-0726-4e93-883b-fe0426d6310a/bbf108c9-7237-49ae-9057-2ccdb71cf675.flv?Signature=Hn7ti7U2yG8tehW1ypD1R%2FGUvrg%3D&Expires=1346804833&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q
81
- http_version:
82
- recorded_at: Tue, 04 Sep 2012 23:27:25 GMT
83
- recorded_with: VCR 2.2.4
@@ -1,91 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.opentok.com/hl/archive/delete/200567af-0726-4e93-883b-fe0426d6310a
6
- body:
7
- encoding: US-ASCII
8
- string: test=none
9
- headers:
10
- Accept:
11
- - ! '*/*'
12
- User-Agent:
13
- - Ruby
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- X-Tb-Token-Auth:
17
- - T1==cGFydG5lcl9pZD00NTk3ODImc2lnPTEyMTU4N2FiMGU3YmQzZTVmNjVjOGQxNjQ1NGQ4Y2UxM2RjZTI5YzI6cm9sZT1wdWJsaXNoZXImc2Vzc2lvbl9pZD0xX01YNDBOVGszT0RKLU1USTNMakF1TUM0eGZsUjFaU0JUWlhBZ01EUWdNVFE2TlRNNk1ESWdVRVJVSURJd01USi1NQzQxTWpFeE9ERXpmZyZjcmVhdGVfdGltZT0xMzQ3MDU0OTc3Jm5vbmNlPTAuNTAzNjU0NzIyODY0NzU1Mg==
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Fri, 07 Sep 2012 21:56:12 GMT
27
- Content-Type:
28
- - text/xml; charset=utf-8
29
- Connection:
30
- - keep-alive
31
- Pragma:
32
- - no-cache
33
- Cache-Control:
34
- - no-cache
35
- Content-Length:
36
- - '124'
37
- body:
38
- encoding: US-ASCII
39
- string: ! '<Errors><error code="404"><itemNotFound message="Archive 200567af-0726-4e93-883b-fe0426d6310a
40
- not found"/></error></Errors>
41
-
42
- '
43
- http_version:
44
- recorded_at: Fri, 07 Sep 2012 21:56:17 GMT
45
- - request:
46
- method: get
47
- uri: https://api.opentok.com/hl/archive/delete/200567af-0726-4e93-883b-fe0426d6310a
48
- body:
49
- encoding: US-ASCII
50
- string: ''
51
- headers:
52
- Accept:
53
- - ! '*/*'
54
- User-Agent:
55
- - Ruby
56
- X-Tb-Token-Auth:
57
- - T1==cGFydG5lcl9pZD00NTk3ODImc2lnPTFlNGEyMjBlN2JhOWI1YjJlM2I3ZDcyMDg1MzVkNzkwN2UzMDM1NjA6cm9sZT1wdWJsaXNoZXImc2Vzc2lvbl9pZD0xX01YNDBOVGszT0RKLU1USTNMakF1TUM0eGZsUjFaU0JUWlhBZ01EUWdNVFE2TlRNNk1ESWdVRVJVSURJd01USi1NQzQxTWpFeE9ERXpmZyZjcmVhdGVfdGltZT0xMzUxNTUzNzk0Jm5vbmNlPTAuMTgyMjczODY3NTc2NjAyOA==
58
- response:
59
- status:
60
- code: 404
61
- message: Not Found
62
- headers:
63
- Server:
64
- - nginx
65
- Date:
66
- - Mon, 29 Oct 2012 23:36:32 GMT
67
- Content-Type:
68
- - text/html; charset=utf-8
69
- Connection:
70
- - keep-alive
71
- Pragma:
72
- - no-cache
73
- Cache-Control:
74
- - no-cache
75
- Content-Length:
76
- - '792'
77
- body:
78
- encoding: US-ASCII
79
- string: ! "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html
80
- xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n<head>\n
81
- <title>Server Error 404</title>\n<!-- CSS Imports -->\n<link rel=\"stylesheet\"
82
- href=\"/error/style/black.css\" type=\"text/css\" media=\"screen\" />\n\n<!--
83
- Favorite Icons -->\n<link rel=\"icon\" href=\"/error/img/favicon.ico\" type=\"image/png\"
84
- />\n\n<style type=\"text/css\">\n .red {\n color:#FF0000;\n
85
- \ }\n .bold {\n font-weight: bold;\n }\n</style>\n</head>\n\n<body>\n
86
- \ <div id=\"container\">\n <html>\n <head>\n <title>404 Not Found</title>\n
87
- </head>\n <body>\n <h1>404 Not Found</h1>\n The resource could not be found.<br
88
- /><br />\n\n\n\n </body>\n</html>\n </div>\n</body>\n</html>\n"
89
- http_version:
90
- recorded_at: Mon, 29 Oct 2012 23:36:34 GMT
91
- recorded_with: VCR 2.2.4
@@ -1,41 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.opentok.com/session/create
6
- body:
7
- encoding: US-ASCII
8
- string: partner_id=0&location=localhost
9
- headers:
10
- Accept:
11
- - ! '*/*'
12
- User-Agent:
13
- - Ruby
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- X-Tb-Partner-Auth:
17
- - ! '0:'
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Tue, 04 Sep 2012 23:27:12 GMT
27
- Content-Type:
28
- - text/plain; charset=UTF-8
29
- Transfer-Encoding:
30
- - chunked
31
- Connection:
32
- - keep-alive
33
- body:
34
- encoding: US-ASCII
35
- string: ! '<Errors><error code="403"><notAuthorized message="The API secret
36
- did not match, Invalid credentials passed"/></error></Errors>
37
-
38
- '
39
- http_version:
40
- recorded_at: Tue, 04 Sep 2012 23:27:24 GMT
41
- recorded_with: VCR 2.2.4
@@ -1,46 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.opentok.com/session/create
6
- body:
7
- encoding: US-ASCII
8
- string: partner_id=459782&location=localhost
9
- headers:
10
- Accept:
11
- - ! '*/*'
12
- User-Agent:
13
- - Ruby
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- X-Tb-Partner-Auth:
17
- - 459782:***REMOVED***
18
- response:
19
- status:
20
- code: 200
21
- message: OK
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Tue, 04 Sep 2012 23:27:12 GMT
27
- Content-Type:
28
- - text/xml; charset=utf-8
29
- Connection:
30
- - keep-alive
31
- Pragma:
32
- - no-cache
33
- Cache-Control:
34
- - no-cache
35
- Access-Control-Allow-Origin:
36
- - ! '*'
37
- Content-Length:
38
- - '294'
39
- body:
40
- encoding: US-ASCII
41
- string: ! "<Sessions>\n <Session>\n <session_id>2_MX40NTk3ODJ-fjIwMTItMDktMDQgMjM6Mjc6MTIuNzY3ODY5KzAwOjAwfjAuNTQzNTEwNTE4NjQxfg</session_id>\n
42
- \ <partner_id>459782</partner_id>\n <create_dt>2012-09-04 23:27:12.767869+00:00</create_dt>\n
43
- \ <session_status></session_status>\n </Session>\n</Sessions>\n"
44
- http_version:
45
- recorded_at: Tue, 04 Sep 2012 23:27:24 GMT
46
- recorded_with: VCR 2.2.4
@@ -1,42 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.opentok.com/hl/archive/200567af-0726-4e93-883b-fe0426d6310a/stitch
6
- body:
7
- encoding: US-ASCII
8
- string: test=none
9
- headers:
10
- Accept:
11
- - ! '*/*'
12
- User-Agent:
13
- - Ruby
14
- Content-Type:
15
- - application/x-www-form-urlencoded
16
- X-Tb-Partner-Auth:
17
- - 459782:***REMOVED***
18
- response:
19
- status:
20
- code: 201
21
- message: Created
22
- headers:
23
- Server:
24
- - nginx
25
- Date:
26
- - Tue, 04 Sep 2012 23:27:14 GMT
27
- Content-Type:
28
- - text/plain
29
- Connection:
30
- - keep-alive
31
- Location:
32
- - https://tokbox.com.production.s3.amazonaws.com/459782%2F200567af-0726-4e93-883b-fe0426d6310a%2Fstitch.mp4?Expires=1346887634&AWSAccessKeyId=AKIAI6LQCPIXYVWCQV6Q&Signature=6%2BihfyAJiQGjmf%2FHV1BGCe14rr8%3D
33
- X-Tb-Host:
34
- - oms407-oak.tokbox.com
35
- Content-Length:
36
- - '0'
37
- body:
38
- encoding: US-ASCII
39
- string: ''
40
- http_version:
41
- recorded_at: Tue, 04 Sep 2012 23:27:26 GMT
42
- recorded_with: VCR 2.2.4
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
- require 'rexml/document'
3
- require 'open_tok/exception'
4
-
5
- describe OpenTok::OpenTokException do
6
-
7
- subject { OpenTok::OpenTokException }
8
-
9
- describe "when inhereted" do
10
- it "should include the subclass in the internal structure" do
11
- length = OpenTok::OpenTokException.exceptions.length
12
- Foo = Class.new OpenTok::OpenTokException do
13
- def self.http_code
14
- 1000
15
- end
16
- end
17
- OpenTok::OpenTokException.exceptions.length.should eq length+1
18
- end
19
- end
20
-
21
- describe "when creating an exception" do
22
-
23
- let(:body_error) { "<Errors><error code='404'><itemNotFound message='Archive foo not found'/></error></Errors>"}
24
-
25
- let(:body_unknown_error) { "<Errors><error code='100'></error></Errors>"}
26
-
27
- it "should find the relevant child using the HTTP error code" do
28
- response = REXML::Document.new body_error
29
- OpenTok::OpenTokException.from_error(response).should be_instance_of OpenTok::OpenTokNotFound
30
- end
31
-
32
- it "should return the general exception if unknown HTTP error code" do
33
- response = REXML::Document.new body_unknown_error
34
- OpenTok::OpenTokException.from_error(response).should be_instance_of OpenTok::OpenTokException
35
- end
36
- end
37
-
38
- end
@@ -1,135 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe OpenTok do
4
-
5
- let(:api_key) { '459782' }
6
- let(:api_secret) { '***REMOVED***' }
7
- let(:api_url) { 'http://api.opentok.com/hl' }
8
- let(:host) { 'localhost' }
9
-
10
- subject { OpenTok::OpenTokSDK.new api_key, api_secret }
11
-
12
- describe "test Initializers" do
13
- it "should be backwards compatible if user set api URL with no effect" do
14
- opentok = OpenTok::OpenTokSDK.new api_key, api_secret, {:api_url => "bla bla"}
15
- opentok.api_url.should eq api_url
16
- end
17
-
18
- it "should be OpenTok SDK Object" do
19
- subject.should be_instance_of OpenTok::OpenTokSDK
20
- end
21
-
22
- its(:api_url) { should == api_url }
23
- end
24
-
25
- describe "Generate Sessions" do
26
- use_vcr_cassette "session"
27
-
28
- let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret }
29
-
30
- it "should generate valid session" do
31
- session = opentok.create_session host
32
- session.to_s.should match(/\A[0-9A-z_-]{40,}\Z/)
33
- end
34
-
35
- it "should generate valid p2p session" do
36
- # Creating Session object with p2p enabled
37
- sessionProperties = {OpenTok::SessionPropertyConstants::P2P_PREFERENCE => "enabled"} # or disabled
38
- session = opentok.createSession( @location, sessionProperties )
39
- session.to_s.should match(/\A[0-9A-z_-]{40,}\Z/)
40
- end
41
- end
42
-
43
- describe "invalid Sessions" do
44
- use_vcr_cassette "invalidSession"
45
- it "should raise an exception with an invalid key and secret" do
46
- invalidOT = OpenTok::OpenTokSDK.new 0, ''
47
-
48
- expect{
49
- session = invalidOT.create_session host
50
- }.to raise_error OpenTok::OpenTokException
51
- end
52
- end
53
-
54
- describe "Generate Tokens" do
55
- let(:session) { subject.createSession host }
56
-
57
- it "should raise error" do
58
- expect { subject.generateToken({:role=>OpenTok::RoleConstants::MODERATOR}) }.to raise_error
59
- end
60
- it "should generate valid token" do
61
- token = subject.generate_token({:session_id => session, :role=>OpenTok::RoleConstants::MODERATOR})
62
- token.should match(/(T1==)+[0-9A-z_]+/)
63
- end
64
- it "should generate valid token camelCase" do
65
- token = subject.generateToken({:session_id => session, :role=>OpenTok::RoleConstants::MODERATOR})
66
- token.should match(/(T1==)+[0-9A-z_]+/)
67
- end
68
- it "should be able to set parameters in token" do
69
- token = subject.generate_token :session_id => session, :role=> OpenTok::RoleConstants::PUBLISHER, :connection_data => "username=Bob,level=4"
70
- str = token[4..token.length]
71
- decoded = Base64.decode64(str)
72
- decoded.should match(/.*username%3DBob.*/)
73
- decoded.should match(/.*level%3D4.*/)
74
- end
75
- end
76
-
77
-
78
- describe "Archiving downloads" do
79
- use_vcr_cassette "archives"
80
- let(:api_key) { '459782' }
81
- let(:api_secret) { '***REMOVED***' }
82
- let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret, {:api_url=>""} }
83
- let(:opts) { {:partner_id => api_key, :location=>host} }
84
-
85
- let(:session) { '1_MX40NTk3ODJ-MTI3LjAuMC4xflR1ZSBTZXAgMDQgMTQ6NTM6MDIgUERUIDIwMTJ-MC41MjExODEzfg' }
86
- let(:token) { opentok.generateToken({:session_id => session, :role=>OpenTok::RoleConstants::MODERATOR}) }
87
- let(:archiveId) { "200567af-0726-4e93-883b-fe0426d6310a" }
88
-
89
- it "should have archive resources" do
90
- otArchive = opentok.getArchiveManifest(archiveId, token)
91
- otArchiveResource = otArchive.resources[0]
92
- vid = otArchiveResource.getId()
93
- vid.should match(/[0-9A-z=]+/)
94
- end
95
-
96
- it "should return download url" do
97
- otArchive = opentok.get_archive_manifest(archiveId, token)
98
- otArchiveResource = otArchive.resources[0]
99
- vid = otArchiveResource.getId()
100
- url = otArchive.downloadArchiveURL(vid, token)
101
- url.start_with?('http').should eq true
102
- end
103
- end
104
-
105
- describe "Delete Archives" do
106
- use_vcr_cassette "deleteArchive"
107
- let(:api_key) { '459782' }
108
- let(:api_secret) { '***REMOVED***' }
109
- let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret, {:api_url => ""} }
110
- let(:session) { '1_MX40NTk3ODJ-MTI3LjAuMC4xflR1ZSBTZXAgMDQgMTQ6NTM6MDIgUERUIDIwMTJ-MC41MjExODEzfg' }
111
- let(:token) { opentok.generateToken({:session_id => session, :role=>OpenTok::RoleConstants::PUBLISHER}) }
112
- let(:archiveId) { "200567af-0726-4e93-883b-fe0426d6310a" }
113
-
114
- it "should raise an Exception on item not found" do
115
- expect{
116
- opentok.deleteArchive archiveId, token
117
- }.to raise_error OpenTok::OpenTokException
118
- end
119
- end
120
-
121
- describe "stitch api" do
122
- use_vcr_cassette "stitchArchive"
123
- let(:api_key) { '459782' }
124
- let(:api_secret) { '***REMOVED***' }
125
- let(:opentok) { OpenTok::OpenTokSDK.new api_key, api_secret }
126
- let(:archiveId) { "200567af-0726-4e93-883b-fe0426d6310a" }
127
-
128
- it "should return stitch url" do
129
- a = opentok.stitchArchive archiveId
130
- a[:code].should eq 201
131
- a[:location].start_with?('http').should be_true
132
- end
133
- end
134
-
135
- end