MCPcopy
hub / github.com/dgraph-io/dgraph / TestAuthQueryRewriting

Function TestAuthQueryRewriting

graphql/resolve/auth_test.go:795–840  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

793}
794
795func TestAuthQueryRewriting(t *testing.T) {
796 sch, err := os.ReadFile("../e2e/auth/schema.graphql")
797 require.NoError(t, err, "Unable to read schema file")
798
799 jwtAlgo := []string{jwt.SigningMethodHS256.Name, jwt.SigningMethodRS256.Name}
800
801 for _, algo := range jwtAlgo {
802 result, err := testutil.AppendAuthInfo(sch, algo, "../e2e/auth/sample_public_key.pem", false)
803 require.NoError(t, err)
804 strSchema := string(result)
805
806 authMeta, err := authorization.Parse(strSchema)
807 require.NoError(t, err)
808
809 metaInfo := &testutil.AuthMeta{
810 PublicKey: authMeta.VerificationKey,
811 Namespace: authMeta.Namespace,
812 Algo: authMeta.Algo,
813 ClosedByDefault: authMeta.ClosedByDefault,
814 }
815
816 b := read(t, "auth_query_test.yaml")
817 t.Run("Query Rewriting "+algo, func(t *testing.T) {
818 queryRewriting(t, strSchema, metaInfo, b)
819 })
820
821 t.Run("Mutation Query Rewriting "+algo, func(t *testing.T) {
822 mutationQueryRewriting(t, strSchema, metaInfo)
823 })
824
825 b = read(t, "auth_add_test.yaml")
826 t.Run("Add Mutation "+algo, func(t *testing.T) {
827 mutationAdd(t, strSchema, metaInfo, b)
828 })
829
830 b = read(t, "auth_update_test.yaml")
831 t.Run("Update Mutation "+algo, func(t *testing.T) {
832 mutationUpdate(t, strSchema, metaInfo, b)
833 })
834
835 b = read(t, "auth_delete_test.yaml")
836 t.Run("Delete Query Rewriting "+algo, func(t *testing.T) {
837 deleteQueryRewriting(t, strSchema, metaInfo, b)
838 })
839 }
840}
841
842func TestAuthQueryRewritingWithDefaultClosedByFlag(t *testing.T) {
843 sch, err := os.ReadFile("../e2e/auth/schema.graphql")

Callers

nothing calls this directly

Calls 9

AppendAuthInfoFunction · 0.92
ParseFunction · 0.92
queryRewritingFunction · 0.85
mutationQueryRewritingFunction · 0.85
mutationAddFunction · 0.85
mutationUpdateFunction · 0.85
deleteQueryRewritingFunction · 0.85
readFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected