oauth_broker test file
authorSang-Hun Chung <sanghun.chung@samsung.com>
Wed, 19 Jul 2017 04:17:32 +0000 (13:17 +0900)
committerSang-Hun Chung <sanghun.chung@samsung.com>
Wed, 19 Jul 2017 04:17:32 +0000 (13:17 +0900)
test/oauth_broker/oauth_redirect_uri_handler.js [new file with mode: 0755]
test/oauth_broker/req_auth.html [new file with mode: 0755]

diff --git a/test/oauth_broker/oauth_redirect_uri_handler.js b/test/oauth_broker/oauth_redirect_uri_handler.js
new file mode 100755 (executable)
index 0000000..8540d03
--- /dev/null
@@ -0,0 +1,30 @@
+// configurable variable: HOST_ADDR, PORT, IMAGE_DIR
+const HOST_ADDR = "10.113.63.216"
+const PORT = 8000
+
+const HTTP_OK = 200;
+const HTTP_BAD_REQUEST = 400;
+const HTTP_INTERNAL_ERROR = 500;
+
+var express = require('express');
+var app = express();
+var bodyParser = require('body-parser');
+
+var host_ip = require("ip");
+
+app.use(express.static('public'));
+app.use(bodyParser.urlencoded({ extended: false }));
+
+var server = app.listen(PORT, function () {
+        var host = host_ip.address();
+        var port = server.address().port;
+
+        console.log("OAuth redirect_uri handler listening at http://%s:%s", host, port)
+})
+
+app.get('/oauth_callback', function(req, res) {
+       console.log("auth code: [", req.query.code, "]");
+//     res.sendFile( __dirname + "/" + "test_login.html" );
+       var html = "<!DOCTYPE html>\n<html>\n    <head>\n    </head>\n <body>\n      <h1>CODE [" + req.query.code +"]</h1>\n   </body>\n</html>";
+       res.send(html);
+})
\ No newline at end of file
diff --git a/test/oauth_broker/req_auth.html b/test/oauth_broker/req_auth.html
new file mode 100755 (executable)
index 0000000..275988c
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<body>
+
+<p>Click the button to send req_auth to GITHUB.</p>
+
+<button onclick="reqAuthToGithub()">GITHUB</button>
+
+<script>
+function reqAuthToGithub() {
+    window.open("https://github.com/login/oauth/authorize?client_id=e6bd5594e38b7f268af1&redirect_uri=http://127.0.0.1:8000/oauth_callback");
+
+}
+</script>
+
+</body>
+</html>
+
+