|
| 1 | +// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm) |
| 2 | +// aahframework.org/essentials source code and usage is governed by a MIT style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +package ess |
| 6 | + |
| 7 | +import ( |
| 8 | + "testing" |
| 9 | + |
| 10 | + "aahframework.org/test.v0/assert" |
| 11 | +) |
| 12 | + |
| 13 | +func TestURLValue(t *testing.T) { |
| 14 | + t.Log("Valid URLs") |
| 15 | + for _, u := range []string{ |
| 16 | + "https://aahframework.org", |
| 17 | + "/facebook-auth/callback?code=AQD5-i29_Vn7fNg8VgcV-Uzk_QNO1sx6yO-tJvkRiFaGs1n-wnCxUnvLX0V2q25Tx7JRZAiTds2-DIKrDb8jPEdGquMCedQ_mpMZQxsHmPYeg_cP1Xjy2jHooK-1ZDJZQHXtDSL8FA7r3nVA7WcrCuLZrlrgXq8LnOSAil3oMD-RqPix-nI576GvAPGgiXo6ep_AfS2GaF8A8TOTwl2iwEjB74F23yEukNpz5tmDJVfH02qtrGECuDfaAEPc-4u2wVIIWKCWy3oEEeoEr4zBdzsMtUR1FP3X5yUm0_yAYFP3taAPrpM-5UqtJWmUgaOY-U0&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", |
| 18 | + "https://www.facebook.com/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", |
| 19 | + "https://godoc.org/golang.org/x/oauth2", |
| 20 | + "http://godoc.org/", |
| 21 | + } { |
| 22 | + assert.True(t, IsVaildURL(u)) |
| 23 | + } |
| 24 | + |
| 25 | + t.Log("Absolute URL") |
| 26 | + for _, u := range []string{ |
| 27 | + "https://aahframework.org", |
| 28 | + "https://www.facebook.com/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", |
| 29 | + "https://godoc.org/golang.org/x/oauth2", |
| 30 | + "http://godoc.org/", |
| 31 | + } { |
| 32 | + assert.True(t, IsAbsURL(u)) |
| 33 | + } |
| 34 | + |
| 35 | + t.Log("Error - Absolute URL") |
| 36 | + for _, u := range []string{ |
| 37 | + "://aahframework.org", |
| 38 | + "://", |
| 39 | + "http", |
| 40 | + "https", |
| 41 | + } { |
| 42 | + assert.False(t, IsAbsURL(u)) |
| 43 | + } |
| 44 | + |
| 45 | + t.Log("Relative URL") |
| 46 | + for _, u := range []string{ |
| 47 | + "/facebook-auth/callback?code=AQD5-i29_Vn7fNg8VgcV-Uzk_QNO1sx6yO-tJvkRiFaGs1n-wnCxUnvLX0V2q25Tx7JRZAiTds2-DIKrDb8jPEdGquMCedQ_mpMZQxsHmPYeg_cP1Xjy2jHooK-1ZDJZQHXtDSL8FA7r3nVA7WcrCuLZrlrgXq8LnOSAil3oMD-RqPix-nI576GvAPGgiXo6ep_AfS2GaF8A8TOTwl2iwEjB74F23yEukNpz5tmDJVfH02qtrGECuDfaAEPc-4u2wVIIWKCWy3oEEeoEr4zBdzsMtUR1FP3X5yUm0_yAYFP3taAPrpM-5UqtJWmUgaOY-U0&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", |
| 48 | + "/dialog/oauth?client_id=182958108394860&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Ffacebook-auth%2Fcallback&response_type=code&scope=public_profile+email&state=72du0BBFIPjW4PsWcI21SccfRX-EkojC4dZ49MYJZac", |
| 49 | + "/golang.org/x/oauth2", |
| 50 | + } { |
| 51 | + assert.True(t, IsRelativeURL(u)) |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments